作为开发和生产依赖项而包含的npm安装错误

时间:2018-11-13 18:22:02

标签: javascript node.js npm npm-install package.json

12915 warn whisper-chat-example@1.0.0 No repository field.
12916 warn The package web3 is included as both a dev and production dependency.
12917 verbose type ProcessTerminatedError
12918 verbose stack ProcessTerminatedError: cancel after 1 retries!
12918 verbose stack     at Farm.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/worker-farm/lib/farm.js:87:25)
12918 verbose stack     at Array.forEach (<anonymous>)
12918 verbose stack     at Farm.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/worker-farm/lib/farm.js:81:36)
12918 verbose stack     at ontimeout (timers.js:427:11)
12918 verbose stack     at tryOnTimeout (timers.js:289:5)
12918 verbose stack     at listOnTimeout (timers.js:252:5)
12918 verbose stack     at Timer.processTimers (timers.js:212:10)
12919 verbose cwd /Users/ishansrivastava/Desktop/blocks/Decentralized_Chat
12920 verbose Darwin 18.0.0
12921 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
12922 verbose node v10.1.0
12923 verbose npm  v6.0.1
12924 error cancel after 1 retries!
12925 verbose exit [ 1, true ]

我不明白哪里出了问题。我该如何解决?与同时包含在开发和生产中的行有关吗?

运行npm run dev时,我得到:

sh: cross-env: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! whisper-chat-example@1.0.0 dev: `cross-env NODE_ENV=development webpack-dev-server --hot`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the whisper-chat-example@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

1 个答案:

答案 0 :(得分:0)

如错误所述,您已经在dev和production依赖项中定义了程序包。

如果只需要在开发中使用该程序包,则只能在dev依赖项中对其进行定义。 如果在生产中需要,则将其从devDependencies中删除,并仅在dependecies中对其进行定义。

关于cross-env,您需要使用npm install cross-env -g将其作为全局软件包安装。这样,命令将被识别并且不会返回错误。