我用这一个上reactjs工作
https://github.com/facebookincubator/create-react-app
但是,当我部署到digitalocean ubuntu上16的顶部,我不能跑npm run build
并得到了这是一个错误。
deploy@xxxx:/www/tmdb_admin$ sudo npm run build
[sudo] password for deploy:
> [email protected] build /www/tmdb_admin
> react-scripts build
sh: 1: react-scripts: not found
npm ERR! Linux 4.4.0-57-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "build"
npm ERR! node v7.3.0
npm ERR! npm v4.0.5
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] build: `react-scripts build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] build script 'react-scripts build'.
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 tmdb_admin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! react-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs tmdb_admin
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls tmdb_admin
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /www/tmdb_admin/npm-debug.log
所以这是我的package.json文件。
{
"name": "tmdb_admin",
"version": "0.1.0",
"private": true,
"devDependencies": {
"autoprefixer-stylus": "0.10.0",
"concurrently": "3.0.0",
"react-scripts": "0.6.1",
"stylus": "0.54.5"
},
"dependencies": {
"bulma": "^0.2.3",
"case-sensitive-paths-webpack-plugin": "^1.1.4",
"es6-promise": "^4.0.5",
"font-awesome": "^4.7.0",
"isomorphic-fetch": "^2.2.1",
"jwt-simple": "^0.5.0",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"react-pagify": "^2.1.1",
"react-redux": "^4.4.5",
"react-router": "^2.4.0",
"react-router-redux": "^4.0.4",
"react-slick": "^0.14.5",
"redux": "^3.5.2",
"redux-thunk": "^2.1.0",
"segmentize": "^0.4.1",
"slick-carousel": "^1.6.0"
},
"scripts": {
"start": "react-scripts start",
"watch": "concurrently --names 'webpack, stylus' --prefix name 'npm run start' 'npm run styles:watch'",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"styles": "stylus -u autoprefixer-stylus ./src/css/style.styl -o ./src/css/style.css",
"styles:watch": "stylus -u autoprefixer-stylus -w ./src/css/style.styl -o ./src/css/style.css"
}
}
这是我node
和npm
版本。
deploy@xxxx:~$ node -v
v7.3.0
deploy@xxxx:~$ npm -v
4.0.5
我怎样才能解决这个问题,使npm run build
作品?
谢谢!
今天我有同样的问题,我固定它再次运行安装。
所有你需要做的就是朗姆酒再次命令npm install
到您的项目,所以你就可以再次运行npm start
COMAND!
对我的作品!我希望我帮助!
当您生成创建反应的应用程序内的项目复制到另一个目录(即当它被部署到服务器上),它失败了,因为符号链接不保留。见https://github.com/facebookincubator/create-react-app/issues/200。在react-scripts
文件./node_modules/.bin/
需要被符号链接到./node_modules/react-scripts/bin/react-scripts.js
。使用diff
不会显示的差异,因为符号链接会得到解决。
最简单的解决方案是创建一个临时反应服务器(即在Digitalocean)上的项目,然后利用复制的copy -a
的./node_modules/.bin的内容(而非copy -r
,为了保留符号链接)。
$ create-react-app tempReact
$ cp -a tempReact/node_modules/.bin/* myActualReactApp/node_modules/.bin
另一个解决方案是手动重新创建符号链接。
$ ln -s myActualreactApp/node_modules/react-scripts/bin/react-scripts.js myActualReactApp/node_modules/.bin/react-scripts
跑:
sudo chown -R $USER:$USER '/home/ubuntu/.npm/'
在Linux OS NPM和被的NodeJS使用sudo全球的装机量和的文件所有者是root,通常一个用户只能读取/执行的软件包。当NPM停滞的一种〜/ .npm /文件夹是由根目录中创建。通过运行创建反应的,应用程序,你作为用户执行命令,并创建反应的应用程序内试图修改在由根而不是当前用户所拥有的〜/ .npm /目录下的东西。您需要该目录的所有者更改为你,这样你就可以修改它没有sudo特权。
通常,类似的事情发生在你安装NPM包使用sudo例如须藤NPM安装--save。再由根拥有,例如,当您尝试没有NPM的须藤infrnt更新/ modufy /删除项目新安装的软件包,你将有类似的权限错误。在这种情况下,浏览到您的项目目录,并通过运行改变它的主人:
sudo chown -R $USER:$USER