node.js - npm 开始显示错误,代码为 npm ERR!代码 生命周期

标签 node.js reactjs

当我尝试加载从网络下载的项目时,它显示以下错误。我尝试清理缓存和 npm install 但仍然显示以下错误。

> reactjs-basics@1.0.0 start D:\React\reactjs-basics-11-router
> npm run build


> reactjs-basics@1.0.0 build D:\React\reactjs-basics-11-router
> webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot --history-api-fallback

Hash: e5125e0911e8a3ceea45
Version: webpack 1.15.0
Time: 1807ms
        Asset     Size  Chunks             Chunk Names
    bundle.js     1 MB       0  [emitted]  main
bundle.js.map  1.09 MB       0  [emitted]  main
    + 251 hidden modules
'cp' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactjs-basics@1.0.0 build: `webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot --history-api-fallback`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactjs-basics@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Aqib.Saman\AppData\Roaming\npm-cache\_logs\2018-10-29T06_47_07_547Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactjs-basics@1.0.0 start: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactjs-basics@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Aqib.Saman\AppData\Roaming\npm-cache\_logs\2018-10-29T06_47_07_609Z-debug.log

我尝试按照某些人的说法将 cp 更改为复制,但随后出现以下错误

The syntax of the command is incorrect.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactjs-basics@1.0.0 build: `webpack -d && copy src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot --history-api-fallback`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactjs-basics@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Aqib.Saman\AppData\Roaming\npm-cache\_logs\2018-10-29T08_03_45_949Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactjs-basics@1.0.0 start: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactjs-basics@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Aqib.Saman\AppData\Roaming\npm-cache\_logs\2018-10-29T08_03_46_008Z-debug.log

好像出了什么问题,如果有人能帮忙,我将不胜感激

最佳答案

您的问题来自此处的复制操作webpack -d && cp src/index.html dist/index.html

我假设您使用的是 Windows 操作系统来运行此代码,并且 Windows 中没有 cp 命令。

您应该尝试用此替换上面的内容

     `webpack -d && copy src/index.html dist/index.html`

关于node.js - npm 开始显示错误,代码为 npm ERR!代码 生命周期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53040176/

相关文章:

node.js - 如果数据库中不存在该数组字段值,如何推送该数组字段值?

javascript - 如何将不同键的对象数组合并为一个数组中的一个键

javascript - 等待每个完成在 react 中使用 setState

reactjs - material-ui 框组件是做什么用的?

javascript - ReactJS [生产问题] - TypeError : (void 0) is not a function

Node.js 和分面搜索

javascript - 使用自定义模块路径时 IntelliJ Javascript "Cannot Find Declaration to go to"

angularjs - 如何在虚拟机上访问我的工作 Angular 2 应用程序

javascript - 无法使用 setstate Hook 复制数组

javascript - 不能在 React 中使用 Bootstrap?