【问题标题】:npm install error included as both a dev and production dependencynpm install 错误包含在开发和生产依赖项中
【发布时间】:2019-04-16 15:46:42
【问题描述】:
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.

【问题讨论】:

  • cross-dev 似乎是一个需要全局安装的 npm 包,但事实并非如此。在运行 npm run dev 之前尝试 npm i cross-env -g。

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


【解决方案1】:

正如错误所说,您在开发和生产依赖项中都定义了包。

如果您只需要在开发中使用该包,则必须仅在开发依赖项中定义它。 如果您在生产中需要,请将其从 devDependencies 中删除并仅在依赖项中定义它。

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

【讨论】:

    猜你喜欢
    • 2018-01-26
    • 1970-01-01
    • 2022-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-17
    • 1970-01-01
    • 2022-09-23
    相关资源
    最近更新 更多