在我的 MacBook 上,我尝试将多个全局 Node 包(包括 cordova)从最新的 Node 版本 9.6.1 迁移到较旧的 Node 版本 5.4.1。
终端命令:
marty@MettBook:~$ nvm install 5.4.1 --reinstall-packages-from=9.6.1
输出:
v5.4.1 is already installed.
Now using node v5.4.1 (npm v3.3.12)
Reinstalling global packages from v9.6.1...
npm WARN deprecated bower@1.7.2: ...psst! Your project can stop working at any moment because its dependencies can change. Prevent this by migrating to Yarn: https://bower.io/blog/2017/how-to-migrate-away-from-bower/
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN checkPermissions Missing write access to /Users/marty/.nvm/versions/node/v9.6.1/lib/node_modules/cordova/node_modules/acorn-node/node_modules
npm WARN checkPermissions Missing write access to /Users/marty/.nvm/versions/node/v9.6.1/lib/node_modules/cordova/node_modules/detective/node_modules
/Users/marty/.nvm/versions/node/v9.6.1/lib
├── bower@1.7.2
├─┬ cordova@6.5.0
│ ├─┬ cordova-lib@6.5.0
│ │ └─┬ cordova-js@4.2.1
│ │ └─┬ browserify@13.3.0
│ │ ├─┬ module-deps@4.1.1
│ │ │ └─┬ detective@4.7.1
│ │ │ └── acorn@5.5.1
│ │ ├── readable-stream@2.3.5
│ │ └─┬ syntax-error@1.4.0
│ │ └─┬ acorn-node@1.3.0
│ │ └── acorn@5.5.1
│ └─┬ insight@0.8.4
│ └─┬ request@2.83.0
│ └── safe-buffer@5.1.1
└─┬ gulp@3.9.1
└─┬ gulp-util@3.0.8
└─┬ through2@2.0.3
└─┬ readable-stream@2.3.5
├── safe-buffer@5.1.1
└─┬ string_decoder@1.0.3
└── safe-buffer@5.1.1
错误输出:
npm ERR! Darwin 17.4.0
npm ERR! argv "/Users/marty/.nvm/versions/node/v5.4.1/bin/node" "/Users/marty/.nvm/versions/node/v5.4.1/bin/npm" "install" "-g" "--quiet" "bower@1.7.2" "cordova@6.5.0" "gulp@3.9.1"
npm ERR! node v5.4.1
npm ERR! npm v3.3.12
npm ERR! path /Users/marty/.nvm/versions/node/v9.6.1/lib/node_modules/cordova/node_modules/acorn-node/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/Users/marty/.nvm/versions/node/v9.6.1/lib/node_modules/cordova/node_modules/acorn-node/node_modules'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, access '/Users/marty/.nvm/versions/node/v9.6.1/lib/node_modules/cordova/node_modules/acorn-node/node_modules']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/Users/marty/.nvm/versions/node/v9.6.1/lib/node_modules/cordova/node_modules/acorn-node/node_modules' }
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! /usr/local/Cellar/nvm/0.33.8/npm-debug.log
Linking global packages from v9.6.1...
这是我的完整 npm-debug.log:https://www.dropbox.com/s/a206meg3nbhfoc2/npm-debug_1.log?dl=0
我尝试通过向每个人授予此路径的完全权限来解决此问题:
sudo chmod 777 /Users/marty/.nvm/versions/node/v9.6.1/lib/node_modules/cordova/node_modules/detective/node_modules/acorn
这没有帮助,错误仍然存在。
不幸的是,I cannot even use sudo
with nvm
。我能做什么?
最佳答案
我找到了 How to execute "sudo nvm"? 的解决方案,因此我可以通过以 super 用户身份执行此任务来绕过此问题。
关于node.js - 如何使用 NVM 将全局 cordova 包(acorn-node)迁移到旧 Node 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49154884/