28

I was running an Electron project, and everything worked just fine. But now when I run any of the scripts in my package.json (including npm start), it just escapes a line and doesn't do anything.

command line screenshot

My package.json:

{
  "name": "interclip-desktop",
  "version": "0.0.7",
  "description": "Interclip for desktop",
  "repository": "https://github.com/aperta-principium/Interclip-desktop",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "package-mac": "electron-packager . --overwrite --asar=true --platform=darwin --arch=x64 --icon=assets/icons/mac/icon.icns --prune=true --out=release-builds",
    "package-win": "electron-packager . Interclip --overwrite --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"Interclip\"",
    "package-linux": "electron-packager . Interclip --overwrite --asar=true --platform=linux --arch=x64 --icon=assets/icons/png/icon.png --prune=true --out=release-builds",
    "win-install": "node installers/windows/createinstaller.js",
    "postinstall": "electron-builder install-app-deps",
    "build": "electron-builder --linux",
    "release": "electron-builder --linux --publish always"
  },
  "keywords": [
    "Desktop",
    "Interclip"
  ],
  "author": "Filip Troníček",
  "license": "MIT",
  "devDependencies": {
    "electron": "^7.1.2",
    "electron-builder": "^22.1.0",
    "electron-installer-dmg": "^3.0.0",
    "electron-packager": "^14.1.1",
    "electron-reload": "^1.5.0",
    "electron-winstaller": "^4.0.0"
  },
  "dependencies": {
    "axios": "^0.19.0",
    "mousetrap": "^1.6.3"
  },
  "build": {
    "appId": "com.aperta-principium.interclip",
    "productName": "Interclip",
    "mac": {
      "category": "public.app-category.utilities"
    },
    "dmg": {
      "icon": false
    },
    "linux": {
      "target": [
        "AppImage"
      ],
      "category": "Utility"
    }
  }
}

I tried updating NPM, didn't work. When I tried in different projects, also doesn't work.

Thanks in advance

Community
  • 1
  • 1
Filip Troníček
  • 434
  • 1
  • 5
  • 14

2 Answers2

60

npm has a ignore-scripts configuration key. It's expected value is a Boolean and it's set to false by default.

Perhaps it has inadvertently been set to true.

To get/set the ignore-scripts configuration you can utilize the npm-config command:

  1. Check its current setting by running:

    npm config get ignore-scripts
    
  2. If the aforementioned command returns true then reset it to false by running:

    npm config set ignore-scripts false
    
RobC
  • 22,977
  • 20
  • 73
  • 80
  • Setting `ignore-scripts` to `false` is [not secure](https://www.youtube.com/watch?v=24tQRwIRP_w&list=PLQhqTW7Ek4ARtck8bgHSWEx90YteK76Ne&t=1046s) actually – 109149 Oct 25 '20 at 20:48
  • 1
    npm config get ignore-scripts and npm --help don't work for me, npm runs and returns nothing instantly. – Owl Mar 31 '21 at 13:27
  • 1
    Life-saving answer, @RobC. Thank you. I only have a passing familiarity with `npm` and I would never have figured this out on my own. 200 rep bounty coming your way. – Rounin Aug 29 '21 at 15:11
  • 2
    `npm config get ignore-scripts` doesn't return nothing in the terminal, it's empty line again – Mathias Osterhagen Jun 30 '22 at 14:29
2

If you are using an integrated terminal (such as the VsCode integrated terminal) try running your npm "run dev' command from your PowerShell (or cmd) terminal. This error arises as a result of your integrated terminal not recognizing your command (especially if you created your app with a git bash terminal).

Try this, and I hope it helps someone cause it always works for me. Cheers!!!

Carliyke
  • 47
  • 4