Ubuntu 升级npm 以及安装cross-env 过程中遇到的问题
npm 安装过程中出现的问题:
1. npm的升级:
npm升级流程如下:
sudo npm cache clean -f sudo npm install -g n sudo n stable
升级的原因,在npm install 的时候出现下面的错误:
..................... npm ERR! Error: No dist in undefined package npm ERR! at next (/usr/share/npm/lib/cache.js:746:26) npm ERR! at /usr/share/npm/lib/cache.js:739:5 npm ERR! at saved (/usr/share/npm/node_modules/npm-registry-client/lib/get.js:142:7) npm ERR! at /usr/lib/nodejs/graceful-fs/polyfills.js:133:7 npm ERR! at Object.oncomplete (fs.js:107:15) npm ERR! If you need help, you may report this log at: npm ERR! <http://github.com/isaacs/npm/issues> npm ERR! or email it to: npm ERR! <npm-@googlegroups.com> npm ERR! System Linux 4.4.0-137-generic npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" npm ERR! cwd /home/darrykinger/blog57 npm ERR! node -v v0.10.25 npm ERR! npm -v 1.3.10 .............
参考github 牛人的提示说,这是由于其npm的版本比较旧了,要使用比较新的版本,大于1版本的比较好
2. cross-env命令找不到,错误提示如下:
darrykinger@darrykinger-laravel:/mnt/hgfs/workspace/blog57$ sudo npm run dev [sudo] password for darrykinger: > @ dev /mnt/hgfs/workspace/blog57 > npm run development > @ development /mnt/hgfs/workspace/blog57 > cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js sh: cross-env: 未找到命令 npm ERR! file sh npm ERR! code ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js` npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the @ development 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! /home/darrykinger/.npm/_logs/2019-04-08T12_10_14_667Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! @ dev: `npm run development` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the @ dev 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! /home/darrykinger/.npm/_logs/2019-04-08T12_10_14_678Z-debug.log
错误分析:
没有找到cross-env包
解决方案,安装cross-env
sudo npm install cross-env
3. 我在安装crosfs-env的情况,这种情况出现的错误如下:
darrykinger@darrykinger-laravel:/mnt/hgfs/workspace/blog57$ sudo npm install cross-env npm ERR! path ../semver/bin/semver npm ERR! code ENOTSUP npm ERR! errno -95 npm ERR! syscall symlink npm ERR! nospc ENOTSUP: operation not supported on socket, symlink '../semver/bin/semver' -> '/mnt/hgfs/workspace/blog57/node_modules/.bin/semver' npm ERR! nospc There appears to be insufficient space on your system to finish. npm ERR! nospc Clear up some disk space and try again. npm ERR! A complete log of this run can be found in: npm ERR! /home/darrykinger/.npm/_logs/2019-04-08T12_13_05_644Z-debug.log npm ERR! nospc ENOTSUP: operation not supported on socket, symlink '../semver/bin/semver'
错误原因分析:
我的项目所在目录,是通过vmware 的文件共享功能,将window 的一个目录,共享到vmware 的linux中去,通过挂载到/mnt/hgfs/workspace/my_project_dir 下,
而挂载的目录,通过执行ln -s 的时候,发现不能 支持建立软连接 ,只有是属于系统本身的目录才能进行软连接处理
将项目移动到/home/current_user_name/ 下,然后执行以上命令,发现没有问题了。
联系我->邮件写信