-->

Getting error while scaffolding angular app

2020-07-16 02:55发布

问题:

I am using yeoman as a scaffolding tool and I am getting the following error . Could anyone please help me out in this. I am using windows 8 environment.

karma-jasmine@0.1.5 node_modules\karma-jasmine
npm WARN optional dep failed, continuing imagemin-optipng@1.0.0
npm WARN optional dep failed, continuing imagemin-jpegtran@1.0.0
npm ERR! EEXIST, open 'C:\Users\shouvik-usr\AppData\Roaming\npm-cache\4230a95c-m
-cache-lodash-2-4-1-package-tgz.lock'
File exists: C:\Users\shouvik-usr\AppData\Roaming\npm-cache\4230a95c-m-cache-lod
ash-2-4-1-package-tgz.lock
Move it away, and try again.

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program File
s (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\Shouvik Data\work\try
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! path C:\Users\shouvik-usr\AppData\Roaming\npm-cache\4230a95c-m-cache-lo
dash-2-4-1-package-tgz.lock
npm ERR! code EEXIST
npm ERR! errno 47
npm ERR! not ok code 0

回答1:

Temporary solution

Run npm install manually when yeoman task is done - it's without problems then.

Permanent solution

The better way is to update your npm tool. Open cmd as the admin and go into nodejs folder, on Windows it's typicaly C:\Program Files\nodejs or C:\Program Files (x86)\nodejs. Than run npm install npm@next and check the version by npm -v (you can check current version here).

If it's not possible e.g. because of permissions you can install the new npm version into another directory and then replace the old version by the new version.

Be aware of installation with -g flag: the default locaiton for global installation on Windows is %APPDATA%/npm and not nodejs installation folder - if you install it this way you have to move npm files into it.

I also recommend to backup your original npm files and in the case of failure to restore it - better save than sorry.