简体   繁体   English

升级node.js和ionic后,ionic服务无法正常工作

[英]ionic serve is not working after upgrading node.js and ionic

I upgraded node.js and npm and did an npm install and now I'm getting the message below. 我升级了node.js和npm并进行了npm安装,现在我收到以下消息。 The thing is, I have been working on the application for about a year and gulp-sass is installed (it's what I use to upgrade my sass files) so it is clearly do to the upgrade, but I'm not sure how to get everything to work again, sort of downgrading everything again. 事实是,我已经在应用程序上工作了大约一年,并且已经安装了gulp-sass(这是我用来升级sass文件的方式),因此显然可以升级,但是我不确定如何获取一切都可以再次工作,有点降级了一切。

$ ionic serve
Uh oh! Looks like you're missing a module in your gulpfile:
Cannot find module 'gulp-sass'

Do you need to run `npm install`?

When I try npm install gulp-sass : 当我尝试npm install gulp-sass

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN enoent ENOENT: no such file or directory, open 'E:\xampp\htdocs\cgf\rcredits-mobile\node_modules\gulp-minify-css\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'E:\xampp\htdocs\cgf\rcredits-mobile\node_modules\karma-junit-reporter\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'E:\xampp\htdocs\cgf\rcredits-mobile\node_modules\karma-mocha-reporter\package.json'
npm WARN rcreditsmobile@1.1.1 No repository field.
npm WARN rcreditsmobile@1.1.1 No license field.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Users\\Public\\Programs\\nodejs\\node.exe" "C:\\Users\\Someone\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "gulp-sass" "--save"
npm ERR! node v6.9.5
npm ERR! npm  v4.2.0
npm ERR! path E:\xampp\htdocs\cgf\rcredits-mobile\node_modules\node-sass
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename

npm ERR! Error: EPERM: operation not permitted, rename 'E:\xampp\htdocs\cgf\rcredits-mobile\node_modules\node-sass' -> 'E:\xampp\htdocs\cgf\rcredits-mobile\node_modules\.node-sass.DELETE'
npm ERR!     at moveAway (C:\Users\Someone\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:42:5)
npm ERR!     at destStatted (C:\Users\Someone\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:31:7)
npm ERR!     at C:\Users\Someone\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'E:\xampp\htdocs\cgf\rcredits-mobile\node_modules\node-sass' -> 'E:\xampp\htdocs\cgf\rcredits-mobile\node_modules\.node-sass.DELETE'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, rename 'E:\xampp\htdocs\cgf\rcredits-mobile\node_modules\node-sass' -> 'E:\xampp\htdocs\cgf\rcredits-mobile\node_modules\.node-sass.DELETE'
npm ERR!     at moveAway (C:\Users\Someone\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:42:5)
npm ERR!     at destStatted (C:\Users\Someone\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:31:7)
npm ERR!     at C:\Users\Someone\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'E:\xampp\htdocs\cgf\rcredits-mobile\node_modules\node-sass' -> 'E:\xampp\htdocs\cgf\rcredits-mobile\node_modules\.node-sass.DELETE'
npm ERR!     at Error (native) parent: 'rcreditsmobile' }
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!     C:\Users\Someone\AppData\Roaming\npm-cache\_logs\2017-02-11T01_17_29_643Z-debug.log

I found an answer on the ionic forum that works, the relevant part is below with a few modifications for clarity: 我在离子论坛上找到了一个可行的答案,为清晰起见,以下相关部分进行了一些修改:

Just add this to your gulpfile.js 只需将其添加到您的gulpfile.js

 gulp.task('serve:before', ['default']); 

That line tells the new ionic 2 client to run the old ionic 1.x client 'default' task before serving (before running ionic serve) 该行告诉新的ionic 2客户端在服务之前(运行离子服务之前)运行旧的ionic 1.x客户端“默认”任务。

Also you need to add your ionic.config.json file this: 另外,您还需要添加以下文件:ionic.config.json:

 { ... "app_id": "", "v2": false, "typescript": false, "watch": { "sass": ["scss/**/*.scss"], "html": ["www/**/*.html"], "livereload": [ "www/**/*.html", "www/**/*.js", "www/**/*.css" ] } ... } 

Ref: https://forum.ionicframework.com/t/ionic2-cli-doesnt-run-gulp-tasks-on-ionic-serve/49085/7 参考: https : //forum.ionicframework.com/t/ionic2-cli-doesnt-run-gulp-tasks-on-ionic-serve/49085/7

I've encountered this problem before. 我以前遇到过这个问题。 What I've tried so far: 到目前为止,我已经尝试过:

  1. Reinstall the node.js. 重新安装node.js。 You may refer https://nodejs.org/en/download/ 您可以参考https://nodejs.org/en/download/
  2. Run in command line: npm rebuild node-sass 在命令行中运行: npm rebuild node-sass

Then try run ionic serve . 然后尝试运行ionic serve Hope it helps you. 希望对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM