0
我有问题在豆茎上部署我的Hello World世界reactjs应用程序。 我这样做,当我想手动运行它: 1)npm开始sh:webpack:命令没有找到错误,当我上传我的Hello World世界reactjs项目上豆茎
然后该项目是建立和复制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"
}
当我部署在魔豆的项目中,我得到以下错误:
sh: webpack: command not found
而且错误的完成堆在本月底加张贴更多细节。 我搜索了很多,它似乎是全球设置的webpack的问题,所以我甚至使用预安装设置全球webpack,但没有结果。任何想法或任何帮助表示赞赏
完整的堆栈错误:
-------------------------------------
/var/log/nodejs/nodejs.log
-------------------------------------
npm ERR!
npm ERR! Failed at the [email protected] 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! [email protected] start: `npm run build && node server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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
> [email protected] start /var/app/current
> npm run build && node server
> [email protected] build /var/app/current
> webpack -d && xcopy "src/index.html" "dist/index.html" /F /Y
sh: webpack: command not found
更新:我的依赖和开发的依赖性如下:
"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"
}
看起来你不是'webpack'安装有别。它在'devDependencies'上吗?你在'production'中安装'devDependencies'吗?那么,如果通过npm运行脚本,则不需要指向路径,将'node_modules/.bin/webpack'更改为'webpack' – Hitmands
Thanks @Hitmands实际上,我的webpack中的devdependencies位不是依赖关系本身。我在没有node_modules/.bin /的情况下尝试了它,并且它不工作。你认为我应该在依赖中添加webpack吗? –
我也用我的package.json的依赖关系和dev-dependencies更新了我的帖子 –