【问题标题】:Errors when running "npm install" on cloned vuejs project在克隆的 vuejs 项目上运行“npm install”时出错
【发布时间】:2018-07-21 23:40:27
【问题描述】:

Nodejs v4.2.6, Npm v3.5.2

最近对 Windows 10 进行了系统重置,然后使用双启动安装了 Ubuntu。我对 Ubuntu 操作系统比较陌生,只知道足够的 Linux 命令来帮助我。当我在我的 VueJs 项目目录中运行 npm install 时,我得到了这个:

> grpc@1.9.0 install /home/george/code/bedal/portal.barcodexchange.com/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

/usr/bin/env: ‘node’: No such file or directory
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.1.3
npm ERR! Linux 4.10.0-28-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! grpc@1.9.0 install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the grpc@1.9.0 install script 'node-pre-gyp install --fallback-to-build --library=static_library'.
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 grpc package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build --library=static_library
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs grpc
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls grpc
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/george/code/bedal/portal.barcodexchange.com/npm-debug.log

尽管出现错误,但我尝试在同一目录中运行“npm run dev”,这就是我得到的:

> barcode_portal@1.0.0 dev /home/george/code/bedal/portal.barcodexchange.com
> node build/dev-server.js

sh: 1: node: not found

npm ERR! Linux 4.10.0-28-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! barcode_portal@1.0.0 dev: `node build/dev-server.js`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the barcode_portal@1.0.0 dev script 'node build/dev-server.js'.
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 barcode_portal package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node build/dev-server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs barcode_portal
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls barcode_portal
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/george/code/bedal/portal.barcodexchange.com/npm-debug.log

这是我的文件目录在 VueJs 项目中的样子:

.   
.babelrc  
config     
.editorconfig  
.eslintrc.js   
.firebaserc  
.gitignore  
node_modules   
package.json   
README.md  
.vscode
..  
build     
debug.log  
.eslintignore  
firebase.json  
.git         
index.html  
npm-debug.log  
.postcssrc.js  
src        
yarn.lock

请注意,该项目在 Windows 安装上运行良好,但现在我无法在 Ubuntu 上启动所有内容。非常感谢您的帮助,感谢您的宝贵时间。

【问题讨论】:

标签: ubuntu npm vue.js npm-install grpc


【解决方案1】:

正如 Roland 指出的那样,您需要在系统上安装 node.js。节点有方向here

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

或者(在我看来,最好的方法)是使用NVM

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

然后

nvm install node && nvm use node

这允许您在需要时快速切换节点版本。

【讨论】:

  • 在发布之前我已经安装了 node.js。我是通过 sudo apt-get install node.js 安装的,这个方法有问题吗? nodejs -v 给我版本,所以我知道它已经安装了
  • 通过 apt 获得的 node.js 已经相当过时了,并且安装为nodejs 而不是node,这是大多数包脚本将尝试执行的。我建议删除该软件包并通过上述方法安装。
猜你喜欢
  • 1970-01-01
  • 2018-08-03
  • 2020-06-08
  • 2016-02-09
  • 2017-10-02
  • 1970-01-01
  • 1970-01-01
  • 2013-08-22
  • 2018-11-22
相关资源
最近更新 更多