sh:webpack:在beanstalk上传my hello world reactjs项目时找不到命令错误

时间:2017-07-18 13:35:17

标签: amazon-web-services webpack elastic-beanstalk package.json amazon-elastic-beanstalk

我在beanstalk上部署mylo world reactjs应用程序时遇到问题。 当我想手动运行它时,我这样做: 1)npm start

然后在dist文件夹上构建并复制项目并且它可以工作。 这是我的package.json脚本部分:

  "scripts": {
"start": "npm run build && node server",
"build": "node_modules/.bin/webpack -d && xcopy \"src/index.html\" \"dist/index.html\" /F /Y"
}

当我在beanstalk上部署项目时,我收到以下错误:

sh: webpack: command not found

此帖子的最后还添加了一个完整的错误堆栈,以获取更多详细信息。 我搜索了很多,似乎是webpack全局设置的问题,所以我甚至使用preinstall来设置webpack全局,但没有结果。任何想法或任何帮助表示赞赏

完整堆栈错误:

-------------------------------------
/var/log/nodejs/nodejs.log
 -------------------------------------
 npm ERR! 
 npm ERR! Failed at the reactjs-basics@1.0.0 build script 'webpack -d && 
 xcopy "src/index.html" "dist/index.html" /F /Y'.
 npm ERR! Make sure you have the latest version of node.js and npm 
 installed.
  npm ERR! If you do, this is most likely a problem with the reactjs-basics 
  package,
 npm ERR! not with npm itself.
 npm ERR! Tell the author that this fails on your system:
 npm ERR!     webpack -d && xcopy "src/index.html" "dist/index.html" /F /Y
 npm ERR! You can get information on how to open an issue for this project 
 with:
  npm ERR!     npm bugs reactjs-basics
  npm ERR! Or if that isn't available, you can get their info via:
  npm ERR!     npm owner ls reactjs-basics
  npm ERR! There is likely additional logging output above.

   npm ERR! Please include the following file with any support request:
    npm ERR!     /var/app/current/npm-debug.log

   npm ERR! Linux 4.9.32-15.41.amzn1.x86_64
  npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.11.1-linux-
  x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.11.1-linux-
 x64/bin/npm" "start"
 npm ERR! node v6.11.1
 npm ERR! npm  v3.10.10
 npm ERR! code ELIFECYCLE
 npm ERR! reactjs-basics@1.0.0 start: `npm run build && node server`
 npm ERR! Exit status 1
 npm ERR! 
 npm ERR! Failed at the reactjs-basics@1.0.0 start script 'npm run build && 
 node server'.
 npm ERR! Make sure you have the latest version of node.js and npm 
 installed.
 npm ERR! If you do, this is most likely a problem with the reactjs-basics 
  package,
  npm ERR! not with npm itself.
  npm ERR! Tell the author that this fails on your system:
  npm ERR!     npm run build && node server
   npm ERR! You can get information on how to open an issue for this project 
   with:
   npm ERR!     npm bugs reactjs-basics
   npm ERR! Or if that isn't available, you can get their info via:
   npm ERR!     npm owner ls reactjs-basics
   npm ERR! There is likely additional logging output above.

    npm ERR! Please include the following file with any support request:
     npm ERR!     /var/app/current/npm-debug.log

     > reactjs-basics@1.0.0 start /var/app/current
     > npm run build && node server


        > reactjs-basics@1.0.0 build /var/app/current
          > webpack -d && xcopy "src/index.html" "dist/index.html" /F /Y

          sh: webpack: command not found

更新:我的依赖项和dev依赖项如下:

  "dependencies": {
   "react": "^15.4.1",
   "react-dom": "^15.4.1",
    "react-router": "^3.0.0",
    "classnames": "^2.2.5",
    "concurrently": "^3.5.0",
    "express": "^4.14.0",
    "morgan": "^1.7.0",
    "react-scripts": "0.2.1"
    },
   "devDependencies": {
   "babel-core": "^6.20.0",
   "babel-jest": "^19.0.0",
   "babel-loader": "^6.2.9",
    "babel-preset-es2015": "^6.18.0",
    "babel-preset-react": "^6.16.0",
    "babel-preset-stage-0": "^6.16.0",
     "babel-preset-stage-2": "^6.18.0",
     "chai": "^3.5.0",
     "chai-jquery": "^2.0.0",
     "gulp": "^3.9.1",
     "gulp-load-plugins": "^1.4.0",
     "gulp-open": "^2.0.0",
     "ignore-styles": "^5.0.1",
     "webpack": "^1.14.0",
     "webpack-dev-server": "^1.16.2",
      "react-scripts": "0.2.1"
     }

1 个答案:

答案 0 :(得分:0)

我发现了问题:

问题是我的脚本文件,而不是

"build": "node_modules/.bin/webpack -d && xcopy \"src/index.html\" \"dist/index.html\" /F /Y"

应该是

webpack -d && cp src/index.html dist/index.html