如何在同一操作系统中管理不同版本的node.js?
问题描述:
我已经安装了node.js v8.6.0,并且我正在尝试运行v.4.4.3开发的npm模块。它创造的问题是这样的:如何在同一操作系统中管理不同版本的node.js?
$ yo angular-scalatra
+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+
|a|n|g|u|l|a|r| |s|c|a|l|a|t|r|a| |g|e|n|e|r|a|t|o|r|
+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+
[?] What is the name of your application? myapp
[?] What is your default package name? com.mycompany.myapp
create generator.json
create package.json
create bower.json
identical .bowerrc
create Gruntfile.js
identical .gitignore
create sbt
create assembly.sbt
create project/build.properties
create project/build.scala
create project/plugins.sbt
create src/main/resources/logback.xml
create src/main/scala/JettyLauncher.scala
create src/main/scala/ScalatraBootstrap.scala
create src/main/scala/com/mycompany/myapp/data/DatabaseInit.scala
create src/main/scala/com/mycompany/myapp/json/DateSerializer.scala
create src/main/scala/com/mycompany/myapp/data/DatabaseSessionSupport.scala
create src/main/scala/com/mycompany/myapp/models/ScalatraRecord.scala
create src/main/webapp/WEB-INF/web.xml
create src/main/webapp/index.html
create src/main/webapp/css/app.css
create src/main/webapp/js/app.js
create src/main/webapp/js/home/home-controller.js
create src/main/webapp/views/home/home.html
identical .editorconfig
identical .jshintrc
I'm all done. Running bower install & npm install for you to install the required dependencies. If this fails, try running the command yourself.
npm WARN deprecated [email protected]: use grunt-ng-annotate instead
npm WARN deprecated [email protected]: ...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 [email protected]: connect 2.x series is deprecated
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: use ng-annotate instead
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to [email protected]^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to [email protected]^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated [email protected]: connect 2.x series is deprecated
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: Use uuid module instead
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: Use the globby package instead
> [email protected] install /home/limitless/Documents/projects/test/scala/myapp/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory '/home/limitless/Documents/projects/test/scala/myapp/node_modules/ws/build'
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
bufferutil.target.mk:97: recipe for target 'Release/obj.target/bufferutil/src/bufferutil.o' failed
make: Leaving directory '/home/limitless/Documents/projects/test/scala/myapp/node_modules/ws/build'
> [email protected] postinstall /home/limitless/Documents/projects/test/scala/myapp/node_modules/gifsicle
> node index.js
path.js:28
throw new TypeError('Path must be a string. Received ' + inspect(path));
^
TypeError: Path must be a string. Received { url: 'https://raw.github.com/imagemin/gifsicle-bin/v0.1.7/vendor/linux/x64/gifsicle',
name: 'gifsicle',
os: 'linux',
arch: 'x64' }
at assertPath (path.js:28:11)
at Object.basename (path.js:1397:5)
at /home/limitless/Documents/projects/test/scala/myapp/node_modules/download/index.js:35:43
at each (/home/limitless/Documents/projects/test/scala/myapp/node_modules/each-async/each-async.js:63:4)
at module.exports (/home/limitless/Documents/projects/test/scala/myapp/node_modules/download/index.js:33:5)
at /home/limitless/Documents/projects/test/scala/myapp/node_modules/bin-wrapper/index.js:108:20
at /home/limitless/Documents/projects/test/scala/myapp/node_modules/bin-wrapper/index.js:141:24
at /home/limitless/Documents/projects/test/scala/myapp/node_modules/bin-check/index.js:30:20
at /home/limitless/Documents/projects/test/scala/myapp/node_modules/executable/index.js:39:20
at FSReqWrap.oncomplete (fs.js:153:21)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected]:pipobscure/fsevents#7dcdf9fa3f8956610fd6f69f72c67bace2de7138 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN [email protected] requires a peer of [email protected]~0.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected]~0.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected]~0.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected]~0.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected]~0.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected]~0.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of [email protected]~0.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall 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/limitless/.npm/_logs/2017-10-16T16_19_21_976Z-debug.log
,所以我不能够运行的应用程序。你能帮我解决这个问题吗?
答
错误消息显示“路径必须是字符串”,并且显示它收到的path
是一个对象,而不是字符串。
也许你应该使用path.url
而不是path
?
(只是猜测,你应该表现出相应的代码,当你问这些类型的问题。)
+0
谢谢你的回答,但是这个解决方案没有解决我的问题@cybersam –
答
我解决NVM(节点版本管理器)的问题,安装和V4.4.3的Node.js
1 )安装nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
2)如果安装完成,则打开新的终端并列出安装的节点版本。
nvm ls
NVM LS
-> system
node -> stable (-> N/A) (default)
iojs -> N/A (default)
3)安装你想要的node.js的ex.V4.4.3
nvm install v4.4.3
4)设置默认版本是哪个版本的Node.js
nvm alias default v4.4.3
5)运行您的应用程序
$ yo angular-scalatra
+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+
|a|n|g|u|l|a|r| |s|c|a|l|a|t|r|a| |g|e|n|e|r|a|t|o|r|
+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+
[?] What is the name of your application? myapp
[?] What is your default package name? com.mycompany.myapp
create generator.json
create package.json
create bower.json
identical .bowerrc
create Gruntfile.js
identical .gitignore
create sbt
create assembly.sbt
create project/build.properties
create project/build.scala
create project/plugins.sbt
create src/main/resources/logback.xml
create src/main/scala/JettyLauncher.scala
create src/main/scala/ScalatraBootstrap.scala
create src/main/scala/com/mycompany/myapp/data/DatabaseInit.scala
create src/main/scala/com/mycompany/myapp/json/DateSerializer.scala
create src/main/scala/com/mycompany/myapp/data/DatabaseSessionSupport.scala
create src/main/scala/com/mycompany/myapp/models/ScalatraRecord.scala
create src/main/webapp/WEB-INF/web.xml
create src/main/webapp/index.html
create src/main/webapp/css/app.css
create src/main/webapp/js/app.js
create src/main/webapp/js/home/home-controller.js
create src/main/webapp/views/home/home.html
identical .editorconfig
identical .jshintrc
I'm all done. Running bower install & npm install for you to install the required dependencies. If this fails, try running the command yourself.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] No license field.
npm WARN deprecated [email protected]: use grunt-ng-annotate instead
npm WARN engine [email protected]: wanted: {"node":"~0.8 || ~0.10"} (current: {"node":"4.4.3","npm":"2.15.1"})
npm WARN deprecated [email protected]: use ng-annotate instead
npm WARN deprecated [email protected]: ...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 [email protected]: connect 2.x series is deprecated
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN peerDependencies The peer dependency [email protected]~0.2.0 included from karma will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency [email protected]~0.1.0 included from karma will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency [email protected]~0.1.0 included from karma will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency [email protected]~0.1.0 included from karma will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency [email protected]~0.1.0 included from karma will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency [email protected]~0.1.0 included from karma will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency [email protected]~0.1.0 included from karma will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN deprecated [email protected]: connect 2.x series is deprecated
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to [email protected]^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated [email protected]: Use the globby package instead
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to [email protected]^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
> [email protected] postinstall /home/limitless/Documents/projects/test/scala/myapp/node_modules/grunt-autoprefixer
>
npm WARN engine [email protected]: wanted: {"node":">=4.5.0"} (current: {"node":"4.4.3","npm":"2.15.1"})
npm WARN engine [email protected]: wanted: {"node":">=4.5.0"} (current: {"node":"4.4.3","npm":"2.15.1"})
npm WARN engine [email protected]: wanted: {"node":">=4.5.0"} (current: {"node":"4.4.3","npm":"2.15.1"})
npm WARN engine [email protected]: wanted: {"node":">=4.5.0"} (current: {"node":"4.4.3","npm":"2.15.1"})
npm WARN engine [email protected]: wanted: {"node":">=4.5.0"} (current: {"node":"4.4.3","npm":"2.15.1"})
npm WARN engine [email protected]: wanted: {"node":">=4.5.0"} (current: {"node":"4.4.3","npm":"2.15.1"})
npm WARN engine [email protected]: wanted: {"node":">=4.5.0"} (current: {"node":"4.4.3","npm":"2.15.1"})
npm WARN engine [email protected]: wanted: {"node":">=4.5.0"} (current: {"node":"4.4.3","npm":"2.15.1"})
npm WARN optional dep failed, continuing [email protected]
npm WARN deprecated [email protected]: Use uuid module instead
> [email protected] postinstall /home/limitless/Documents/projects/test/scala/myapp/node_modules/grunt-contrib-imagemin/node_modules/pngquant-bin
> node index.js
✓ pre-build test passed successfully
> [email protected] postinstall /home/limitless/Documents/projects/test/scala/myapp/node_modules/grunt-contrib-imagemin/node_modules/optipng-bin
> node index.js
✔ pre-build test passed successfully!
> [email protected] postinstall /home/limitless/Documents/projects/test/scala/myapp/node_modules/grunt-contrib-imagemin/node_modules/jpegtran-bin
> node index.js
✔ pre-build test passed successfully!
> [email protected] postinstall /home/limitless/Documents/projects/test/scala/myapp/node_modules/grunt-contrib-imagemin/node_modules/gifsicle
> node index.js
✔ pre-build test passed successfully!
> [email protected] install /home/limitless/Documents/projects/test/scala/myapp/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory '/home/limitless/Documents/projects/test/scala/myapp/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/build'
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
bufferutil.target.mk:92: recipe for target 'Release/obj.target/bufferutil/src/bufferutil.o' failed
make: Leaving directory '/home/limitless/Documents/projects/test/scala/myapp/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/build'
npm WARN peerDependencies The peer dependency [email protected]^2.1.0 included from karma-requirejs will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN deprecated [email protected]: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
/
> [email protected] install /home/limitless/Documents/projects/test/scala/myapp/node_modules/karma-phantomjs-launcher/node_modules/phantomjs
> node install.js
PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v1.9.19/phantomjs-1.9.8-linux-x86_64.tar.bz2
Saving to /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2
Receiving...
[========================================] 99%
Received 12854K total.
Extracting tar contents (via spawned process)
Removing /home/limitless/Documents/projects/test/scala/myapp/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1508170953450/phantomjs-1.9.8-linux-x86_64 -> /home/limitless/Documents/projects/test/scala/myapp/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /home/limitless/Documents/projects/test/scala/myapp/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs
[email protected] node_modules/karma-jasmine
[email protected] node_modules/grunt-rev
[email protected] node_modules/karma-ng-scenario
[email protected] node_modules/grunt-contrib-concat
[email protected] node_modules/grunt-contrib-copy
[email protected] node_modules/karma-junit-reporter
└── [email protected]
[email protected] node_modules/grunt-contrib-clean
└── [email protected]
[email protected] node_modules/grunt-sync
└── [email protected]
[email protected] node_modules/grunt-concurrent
├── [email protected]
└── [email protected]
[email protected] node_modules/time-grunt
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected] ([email protected], [email protected])
[email protected] node_modules/grunt-contrib-htmlmin
├── [email protected]
└── [email protected] ([email protected])
[email protected] node_modules/grunt-connect-proxy
├── [email protected]
└── [email protected] ([email protected], [email protected])
[email protected] node_modules/grunt-contrib-cssmin
├── [email protected] ([email protected])
└── [email protected] ([email protected])
[email protected] node_modules/grunt-karma
└── [email protected] ([email protected], [email protected])
[email protected] node_modules/grunt-usemin
├── [email protected]
└── [email protected]
[email protected] node_modules/load-grunt-tasks
├── [email protected] ([email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected])
[email protected] node_modules/grunt-svgmin
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
[email protected] node_modules/grunt-autoprefixer
└── [email protected] ([email protected], [email protected])
[email protected] node_modules/grunt-contrib-connect
├── [email protected]
├── [email protected]
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
[email protected] node_modules/grunt-contrib-watch
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected])
[email protected] node_modules/grunt-bower-install
└── [email protected] ([email protected], [email protected])
[email protected] node_modules/grunt-contrib-uglify
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected])
[email protected] node_modules/grunt-ngmin
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
[email protected] node_modules/grunt-contrib-jshint
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
[email protected] node_modules/grunt
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected], [email protected])
[email protected] node_modules/grunt-modernizr
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], cookie-ja[email protected], [email protected], [email protected], [email protected], [email protected])
[email protected] node_modules/grunt-bowercopy
├── [email protected]
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
[email protected] node_modules/grunt-contrib-imagemin
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected])
[email protected] node_modules/karma-script-launcher
[email protected] node_modules/karma-firefox-launcher
[email protected] node_modules/karma-html2js-preprocessor
[email protected] node_modules/karma-chrome-launcher
└── [email protected] ([email protected])
[email protected] node_modules/karma-coffee-preprocessor
└── [email protected] ([email protected])
[email protected] node_modules/requirejs
[email protected] node_modules/karma-requirejs
[email protected] node_modules/karma-phantomjs-launcher
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
[email protected] node_modules/karma
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected])
你应该安装最新版本的节点。 – SLaks
在哪个版本的node.js @SLaks –
删除我的解决方案,因为古斯塔沃穆尼奥斯巴伦苏埃拉更好地制定了它,但这是你的方式。 –