centos7.2安装nodejs、npm走过的坑

 我的环境是win7上装的Oracle VM VirtualBox  

linux系统是centos7.2

安装

wget -c https://nodejs.org/dist/v10.9.0/node-v10.9.0-linux-x64.tar.xz
xz -d node-v10.9.0-linux-x64.tar.xz
tar -xvf node-v10.9.0-linux-x64.tar
mv node-v10.9.0-linux-x64 /usr/local/
ln -s /usr/local/node-v10.9.0-linux-x64/bin/node /usr/local/bin/node
ln -s /usr/local/node-v10.9.0-linux-x64/bin/npm /usr/local/bin/npm
node -v
npm -v
cd /data/httpd/kangaroo_mini_app
npm cache clean --force
npm i

 

接二连三的warning、error  。。。

1、npm ERR! rofs EROFS: read-only file system, symlink '../eslint/bin/eslint.js' ->

解决方法:Enable symlinks

 

VBoxManage setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1
Or on Windows

VBoxManage.exe setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1
where VM_NAME is the name of your virtual machine (e.g Ubuntu) and SHARE_NAME the name of your shared directory (without the "sf_" prefix).

This will re-enable the previous symlink friendly behavior.

Note: On Windows, always restart the Virtual Machine AND VirtualBox GUI.

 

我的是win7上的虚拟机

cmd以管理员身份打开

D:\Program Files\Oracle\VirtualBox>VBoxManage.exe setextradata centos64 VBoxInternal2/SharedFoldersEnableSymlinksCreate/share 1

其中:centos64是虚拟机名称 share是共享文件夹的名称

 

2、npm ERR! Error: EPERM: operation not permitted, rename

npm ERR! Error: EPERM: operation not permitted, rename '/data/httpd/kangaroo_mini_app/node_modules/.staging/abbrev-08eaebb8' -> '/data/httpd/kangaroo_mini_app/node_modules/abbrev'
npm ERR!     at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
npm ERR!     at /usr/lib/node_modules/npm/node_modules.bundled/graceful-fs/polyfills.js:264:29
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR! 
npm ERR! Error: EPERM: operation not permitted, rename '/data/httpd/kangaroo_mini_app/node_modules/.staging/abbrev-08eaebb8' -> '/data/httpd/kangaroo_mini_app/node_modules/abbrev'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, rename '/data/httpd/kangaroo_mini_app/node_modules/.staging/abbrev-08eaebb8' -> '/data/httpd/kangaroo_mini_app/node_modules/abbrev'
npm ERR!     at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
npm ERR!     at /usr/lib/node_modules/npm/node_modules.bundled/graceful-fs/polyfills.js:264:29
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR! 
npm ERR! Error: EPERM: operation not permitted, rename '/data/httpd/kangaroo_mini_app/node_modules/.staging/abbrev-08eaebb8' -> '/data/httpd/kangaroo_mini_app/node_modules/abbrev'
npm ERR!     at Error (native) parent: 'kangaroo' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /data/httpd/kangaroo_mini_app/npm-debug.log

解决方法:关掉win7环境的360

 

后来再执行安装

3、npm ERR! ETXTBSY: text file is busy, rename

npm cache clean --force
npm i
#不行 还是报错 npm ERR! ETXTBSY: text file is busy, rename
npm cache clean --force
npm rebuild node-sass --no-bin-links
npm install --no-bin-links
#不行 还是报错 npm ERR! ETXTBSY: text file is busy, rename
npm install -f

还是报错

 

失望了   改装yarn了

npm cache clean --force
npm install -g yarn
ln -s /usr/local/node-v10.9.0-linux-x64/bin/yarn /usr/local/bin/yarn
[root@localhost kangaroo_mini_app]# yarn install
yarn install v1.9.4
warning package.json: No license field
info No lockfile found.
warning [email protected]: No license field
[1/4] Resolving packages...
warning stylelint > autoprefixer > [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning wepy-plugin-imagemin > imagemin-pngquant > pngquant-bin > bin-wrapper > download > gulp-decompress > [email protected]: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > [email protected]" has incorrect peer dependency "eslint-friendly-formatter@>=2.0.0 < 3.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 538.95s.
[root@localhost kangaroo_mini_app]#yarn run dev
yarn run v1.9.4
warning package.json: No license field
$ run-p start watch:font
warning package.json: No license field
warning package.json: No license field
$ onchange 'icons/*.svg' -- npm run font-build
$ wepy build --watch
/bin/sh: wepy: command not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with signal "SIGTERM".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "start" exited with 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[root@localhost kangaroo_mini_app]# npm install wepy-cli -g
npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
/usr/local/node-v10.9.0-linux-x64/bin/wepy -> /usr/local/node-v10.9.0-linux-x64/lib/node_modules/wepy-cli/bin/wepy.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/wepy-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ [email protected]
added 462 packages from 296 contributors in 41.131s
[root@localhost kangaroo_mini_app]# yarn run dev
yarn run v1.9.4
warning package.json: No license field
$ run-p start watch:font
warning package.json: No license field
warning package.json: No license field
$ wepy build --watch
$ onchange 'icons/*.svg' -- npm run font-build
[05:46:49] [编译] 入口: src/app.wpy

到此可以了

 

 

 

 

其他情况:

yarn add webpack webpack-cli --save-dev

yarn add v1.9.4
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
error An unexpected error occurred: "EPROTO: protocol error, symlink '../../../acorn/bin/acorn' -> '/data/httpd/webpack-demo/node_modules/acorn-dynamic-import/node_modules/.bin/acorn'".
info If you think this is a bug, please open a bug report with the information provided in "/data/httpd/webpack-demo/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

改为:yarn add webpack webpack-cli --save-dev --no-bin-links 

 

 

 

2018.10.17 15:00:00

error An unexpected error occurred: "EPROTO: protocol error, symlink '../jsesc/bin/jsesc' -> '/data/httpd/ec

在https://github.com/npm/npm/issues/9901上看到下面有这样回复的  

centos7.2安装nodejs、npm走过的坑_第1张图片

If you don't want to run virtualbox as administrator, you can allow creating symbolic links for all users:

  1. Open the Local Group Policy Editor (gpedit.msc)
  2. Edit the Create symbolic links policy at:

Computer configuration → Windows Settings → Security Settings → Local Policies → User Rights Assignment → Create symbolic links

便按照此尝试了下  发现成功解决了这个问题  不用再要加上--no-bin-links了

centos7.2安装nodejs、npm走过的坑_第2张图片

centos7.2安装nodejs、npm走过的坑_第3张图片

 

centos7.2安装nodejs、npm走过的坑_第4张图片

centos7.2安装nodejs、npm走过的坑_第5张图片

centos7.2安装nodejs、npm走过的坑_第6张图片

 

centos7.2安装nodejs、npm走过的坑_第7张图片

选择一个  确定 、然后点击应用、 确定即可

 

你可能感兴趣的:(nodejs)