Ubuntu 升級npm 以及安裝cross-env 過程當中遇到的問題

  

npm 安裝過程當中出現的問題:node

1. npm的升級:linux

npm升級流程以下:webpack

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

  升級的緣由,在npm install 的時候出現下面的錯誤:laravel

.....................
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版本的比較好git

 2. cross-env命令找不到,錯誤提示以下:github

 

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

  錯誤分析:web

          沒有找到cross-env包npm

      解決方案,安裝cross-env bash

         

sudo npm install cross-env

3. 我在安裝crosfs-env的狀況,這種狀況出現的錯誤以下:app

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/ 下,而後執行以上命令,發現沒有問題了。

相關文章
相關標籤/搜索