2017-10-16 121 views
-1

我已經安裝了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 

,所以我不能夠運行的應用程序。你能幫我解決這個問題嗎?

+1

你應該安裝最新版本的節點。 – SLaks

+0

在哪個版本的node.js @SLaks –

+0

刪除我的解決方案,因爲古斯塔沃穆尼奧斯巴倫蘇埃拉更好地制定了它,但這是你的方式。 –

回答

1

的解決方案是n先安裝打字

npm install -g n 

,然後用

sudo n 4.4.3 

安裝此安裝將設置你的節點js版在系統中使用

0

錯誤消息顯示「路徑必須是字符串」,並且顯示它收到的path是一個對象,而不是字符串。

也許你應該使用path.url而不是path

(只是猜測,你應該表現出相應的代碼,當你問這些類型的問題。)

+0

謝謝你的回答,但是這個解決方案沒有解決我的問題@cybersam –

0

我解決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]) 
相關問題