NPM运行*不执行任何操作


16

我正在运行一个Electron项目,一切都很好。但是现在,当我运行package.json中的任何脚本(包括npm start)时,它只是转义了一行而没有执行任何操作。

命令行截图

我的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"
    }
  }
}

我尝试更新NPM,但没有用。当我在其他项目中尝试过时,也不起作用。

提前致谢

Answers:


32

npm具有ignore-scripts配置密钥。它的期望值是布尔值false,默认设置为。

可能是由于疏忽而将其设置为true

get/ setignore-scripts配置,你可以利用NPM-配置命令:

  1. 通过运行以下命令检查其当前设置:

    npm config get ignore-scripts
  2. 如果上述命令返回,truefalse通过运行将其重置为:

    npm config set ignore-scripts false

0

如果您使用的是集成终端(例如VsCode集成终端),请尝试从PowerShell(或cmd)终端运行npm“ run dev”命令。由于集成终端无法识别您的命令而导致出现此错误(尤其是如果您使用git bash终端创建了应用)。

试试这个,我希望它可以帮助某人,因为它总是对我有用。干杯!!!

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.