npm / npm

This repository is moving to: https://github.com/npm/cli
http://npm.community
17.54k stars 3.02k forks source link

npm install fails in windows using fsevents #17671

Closed kylelamse closed 7 years ago

kylelamse commented 7 years ago

I'm opening this issue because:

What's going wrong?

When doing an npm install with just a package.json, I get an EPERM which causes an error and installation aborts.

Here is the console output:

C:\Users\kyle.lamse\Code\typescript-webpack>npm i
npm ERR! path C:\Users\kyle.lamse\Code\typescript-webpack\node_modules\fsevents\
node_modules\getpass\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir 'C:\Users\kyle.lamse\Cod
e\typescript-webpack\node_modules\fsevents\node_modules\getpass\node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, scandir 'C:\Users\kyle.lamse\
Code\typescript-webpack\node_modules\fsevents\node_modules\getpass\node_modules'

npm ERR!     at Error (native)
npm ERR!   stack: 'Error: EPERM: operation not permitted, scandir \'C:\\Users\\k
yle.lamse\\Code\\typescript-webpack\\node_modules\\fsevents\\node_modules\\getpa
ss\\node_modules\'\n    at Error (native)',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'scandir',
npm ERR!   path: 'C:\\Users\\kyle.lamse\\Code\\typescript-webpack\\node_modules\
\fsevents\\node_modules\\getpass\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\kyle.lamse\AppData\Roaming\npm-cache\_logs\2017-07-07T16_0
3_08_624Z-debug.log

What's really strange is that it tries to use fsevents which shouldn't be able to be installed/used on Windows. I remember when using npm 5.0.4 there were issues with fsevents which was supposed to be fixed by @zkat in #17552. However, I'm not sure if this issue is related. When I downgrade to npm@4, the issue does not occur.

How can the CLI team reproduce the problem?

Use this package.json in Windows: package.json

Run an npm install

Here is the npm-debug.log file: npm-debug.log

supporting information:

kylelamse commented 7 years ago

Update:

I tried doing an npm install in a fresh directory with the package.json being the only thing in it. It worked fine, but when I ran npm i -D css-loader, I get the same issue as listed in the comment above.

console output:

C:\Users\kyle.lamse\Desktop\typescript-webpack>npm i -D css-loader
npm ERR! path C:\Users\kyle.lamse\Desktop\typescript-webpack\node_modules\fseven
ts\node_modules\getpass\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall lstat
npm ERR! Error: EPERM: operation not permitted, lstat 'C:\Users\kyle.lamse\Deskt
op\typescript-webpack\node_modules\fsevents\node_modules\getpass\node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, lstat 'C:\Users\kyle.lamse\De
sktop\typescript-webpack\node_modules\fsevents\node_modules\getpass\node_modules
'
npm ERR!     at Error (native)
npm ERR!   stack: 'Error: EPERM: operation not permitted, lstat \'C:\\Users\\kyl
e.lamse\\Desktop\\typescript-webpack\\node_modules\\fsevents\\node_modules\\getp
ass\\node_modules\'\n    at Error (native)',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'lstat',
npm ERR!   path: 'C:\\Users\\kyle.lamse\\Desktop\\typescript-webpack\\node_modul
es\\fsevents\\node_modules\\getpass\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\kyle.lamse\AppData\Roaming\npm-cache\_logs\2017-07-07T16_3
3_01_899Z-debug.log

npm-debug.log

egoroof commented 7 years ago

Have the same problem (Windows 10, node 8.1.3). It was ok in 5.0.3 but after updating to 5.1.0 (with npm i -g npm) got this behavior: clean install (without node_modules folder) is ok (and looks faster, maybe faster than yarn?). But when there are installed dependencies exist running npm i causes the problem with fsevents on Windows.

vascofernandes commented 7 years ago

Same problem.

Windows Server 2016 x64 Node 8.0.0 NPM 5.1.0


 2017-07-10T08:34:02.3867032Z > uglifyjs-webpack-plugin@0.4.6 postinstall E:\BldWork\2017.1\2\s\XXXXXXXXXXXXXXXXXX\node_modules\uglifyjs-webpack-plugin
2017-07-10T08:34:02.3867032Z > node lib/post_install.js
2017-07-10T08:34:02.3867032Z 
2017-07-10T08:34:16.3554135Z npm ERR! path E:\BldWork\2017.1\2\s\XXXXXXXXXXXXXXXXXX\node_modules\fsevents\node_modules\dashdash\node_modules
2017-07-10T08:34:16.3554135Z npm ERR! code EPERM
2017-07-10T08:34:16.3554135Z npm ERR! errno -4048
2017-07-10T08:34:16.3554135Z npm ERR! syscall scandir
2017-07-10T08:34:16.3554135Z npm ERR! Error: EPERM: operation not permitted, scandir 'E:\BldWork\2017.1\2\s\XXXXXXXXXXXXXXXXXX\node_modules\fsevents\node_modules\dashdash\node_modules'
2017-07-10T08:34:16.3554135Z npm ERR!  { Error: EPERM: operation not permitted, scandir 'E:\BldWork\2017.1\2\s\XXXXXXXXXXXXXXXXXX\node_modules\fsevents\node_modules\dashdash\node_modules'
2017-07-10T08:34:16.3554135Z npm ERR!   stack: 'Error: EPERM: operation not permitted, scandir \'E:\\BldWork\\2017.1\\2\\s\\XXXXXXXXXXXXXXXXXX\\node_modules\\fsevents\\node_modules\\dashdash\\node_modules\'',
2017-07-10T08:34:16.3554135Z npm ERR!   errno: -4048,
2017-07-10T08:34:16.3554135Z npm ERR!   code: 'EPERM',
2017-07-10T08:34:16.3554135Z npm ERR!   syscall: 'scandir',
2017-07-10T08:34:16.3554135Z npm ERR!   path: 'E:\\BldWork\\2017.1\\2\\s\\XXXXXXXXXXXXXXXXXX\\node_modules\\fsevents\\node_modules\\dashdash\\node_modules' }
2017-07-10T08:34:16.3554135Z npm ERR! 
2017-07-10T08:34:16.3554135Z npm ERR! Please try running this command again as root/Administrator.
2017-07-10T08:34:16.4647883Z 
markwhitfeld commented 7 years ago

Same here, fails in 5.1.0 but works in 5.0.3. Fails even if I delete the node_modules folder before running 'npm install'. (Windows 10, node v7.9.0)

CarolineBoyer commented 7 years ago

Same problem. Uploading to npm 5.2.0 didn't seem to do the trick either. However ( might be a coincidence) doing npm cache verify then npm i my package again worked.

pocesar commented 7 years ago

this was a real blocker, had to go back to npm@4.6.1. the EPERM error is constant in Windows 10 (latest updates). although it DOESN'T seem like a problem with permissions per se, it looks like npm (or node) is being picky about how many processes are currently reading from the same file (ie: vscode, antivirus scanners, firewalls, having the explorer folder open, cmd.exe, etc). when I shutdown everything, it works 90% of the time. react-native (related) metro bundler happens to have the same problem, so it goes beyond npm itself. when compiling the react-native Java project, I have to close everything else it'll EPERM out

gforceg commented 7 years ago

I'm getting the same error in windows 10 npm 5.2.0. I deleted node_modules and ran npm cahce verify and it seemed to work. but if I add another package to my project via 'npm i --save ' I bet it will fail again.

bohoffi commented 7 years ago

I solved the issue by returning to npm@5.0.3 but I hope that it will get fixed so that I can update again.

zkat commented 7 years ago

gonna take a look at this. This is weird.

zkat commented 7 years ago

Heads up: I'm unable to reproduce this with either the latest npm (5.3.0), or the original reported one(s) (5.0.3, 5.0.4, 5.1.0) on my Windows installation. Tried every combo posted here, a few times. :\

gforceg commented 7 years ago

Hi @zkat:

try running this:

git clone https://github.com/mgechev/angular-seed
cd angular-seed
npm i

The above works without issue for me when I am running npm 5.0.3, but there are multiple errors in 5.3.0.

Below is a my git-bash terminal output:

<USER>@localhost MINGW64 ~/src/my-stuff
$ npm --version
5.3.0
<USER>@localhost MINGW64 ~/src/my-stuff
$ node --version
v8.1.4

<USER>@localhost MINGW64 ~/src/my-stuff
$ git clone https://github.com/mgechev/angular-seed
Cloning into 'angular-seed'...
remote: Counting objects: 10055, done.
remote: Compressing objects: 100% (40/40), done.
remote: Total 10055 (delta 21), reused 32 (delta 11), pack-reused 10004
Receiving objects: 100% (10055/10055), 3.21 MiB | 1.95 MiB/s, done.
Resolving deltas: 100% (5902/5902), done.

<USER>@localhost MINGW64 ~/src/my-stuff
$ cd angular-seed/

<USER>@localhost MINGW64 ~/src/my-stuff/angular-seed (master)
$ npm i

> weak@1.0.1 install C:\Users\<USER>\src\my-stuff\angular-seed\node_modules\weak
> node-gyp rebuild

C:\Users\<USER>\src\my-stuff\angular-seed\node_modules\weak>if not defined npm_config_node_gyp (node "C:\Programs\APPS\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere.  [C:\Users\<USER>\src\my-stuff\angular-seed\node_modules\weak\build\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Programs\APPS\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Programs\\APPS\\nodejs\\node.exe" "C:\\Programs\\APPS\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\<USER>\src\my-stuff\angular-seed\node_modules\weak
gyp ERR! node -v v8.1.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

> node-sass@4.5.3 install C:\Users\<USER>\src\my-stuff\angular-seed\node_modules\node-sass
> node scripts/install.js

Cached binary found at C:\Programs\APPS\npm-cache\node-sass\4.5.3\win32-x64-57_binding.node

> node-sass@4.5.3 postinstall C:\Users\<USER>\src\my-stuff\angular-seed\node_modules\node-sass
> node scripts/build.js

Binary found at C:\Users\<USER>\src\my-stuff\angular-seed\node_modules\node-sass\vendor\win32-x64-57\binding.node
Testing binary
Binary is fine
npm ERR! path C:\Users\<USER>\src\my-stuff\angular-seed\node_modules\fsevents\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir 'C:\Users\<USER>\src\my-stuff\angular-seed\node_modules\fsevents\node_modules'
npm ERR!  { Error: EPERM: operation not permitted, scandir 'C:\Users\<USER>\src\my-stuff\angular-seed\node_modules\fsevents\node_modules'
npm ERR!   stack: 'Error: EPERM: operation not permitted, scandir \'C:\\Users\\<USER>\\src\\my-stuff\\angular-seed\\node_modules\\fsevents\\node_modules\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'scandir',
npm ERR!   path: 'C:\\Users\\<USER>\\src\\my-stuff\\angular-seed\\node_modules\\fsevents\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
gforceg commented 7 years ago

I ran it a second time and it got a little further.

<USER>@localhost MINGW64 ~/src/my-stuff/angular-seed (master)
$ npm i

> weak@1.0.1 install C:\<USER>s\<USER>\src\my-stuff\angular-seed\node_modules\weak
> node-gyp rebuild

C:\<USER>s\<USER>\src\my-stuff\angular-seed\node_modules\weak>if not defined npm_config_node_gyp (node "C:\Programs\<USER>@localhost\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere.  [C:\<USER>s\<USER>\src\my-stuff\angular-seed\node_modules\weak\build\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Programs\<USER>@localhost\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Programs\\<USER>@localhost\\nodejs\\node.exe" "C:\\Programs\\<USER>@localhost\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\<USER>s\<USER>\src\my-stuff\angular-seed\node_modules\weak
gyp ERR! node -v v8.1.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

> node-sass@4.5.3 install C:\<USER>s\<USER>\src\my-stuff\angular-seed\node_modules\node-sass
> node scripts/install.js

Cached binary found at C:\Programs\<USER>@localhost\npm-cache\node-sass\4.5.3\win32-x64-57_binding.node

> node-sass@4.5.3 postinstall C:\<USER>s\<USER>\src\my-stuff\angular-seed\node_modules\node-sass
> node scripts/build.js

Binary found at C:\<USER>s\<USER>\src\my-stuff\angular-seed\node_modules\node-sass\vendor\win32-x64-57\binding.node
Testing binary
Binary is fine

> angular-seed@1.0.0 postinstall C:\<USER>s\<USER>\src\my-stuff\angular-seed
> gulp check.versions && gulp build.bundle.rxjs && npm prune && gulp webdriver && gulp print.banner

[15:14:33] Requiring external module ts-node/register
[15:14:41] Loading tasks folder C:\<USER>s\<USER>\src\my-stuff\angular-seed\tools\tasks\seed
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.assets.dev
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.assets.prod
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.bundle.rxjs
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.bundles.app.aot
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.bundles.app.rollup.aot
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.bundles.app
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.bundles
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.docs
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.html_css
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.index.dev
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.index.prod
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.js.dev
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.js.e2e
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.js.prod.aot
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.js.prod.rollup.aot
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.js.prod
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.js.test
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.tools
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\check.tools
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\check.versions
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\clean.all
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\clean.coverage
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\clean.dev
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\clean.e2e
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\clean.prod
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\clean.tools
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\clear.files
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\compile.ahead.prod
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\copy.prod.rollup.aot
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\copy.prod
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\e2e
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\generate.manifest
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\i18n.build
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\i18n.merge
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\karma.run
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\karma.run.without_coverage
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\karma.run.with_coverage
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\karma.watch
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\minify.bundles
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\minify.index
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\noop
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\print.banner
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\serve.coverage
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\serve.coverage.watch
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\serve.docs
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\server.prod
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\server.start
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\start.deving
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\sw.manifest.static
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\test.watch
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\transpile.bundles.rollup.aot
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\tslint
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\watch.dev
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\watch.e2e
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\watch.test
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\webdriver
[15:14:41] Loading tasks folder C:\<USER>s\<USER>\src\my-stuff\angular-seed\tools\tasks\project
[15:14:41] Registering task ~\src\my-stuff\angular-seed\tools\tasks\project\sample.task
[15:14:41] Using gulpfile ~\src\my-stuff\angular-seed\gulpfile.ts
[15:14:41] Starting 'check.versions'...
[15:14:41] Finished 'check.versions' after 242 ms
[15:17:53] Requiring external module ts-node/register
[15:17:54] Loading tasks folder C:\<USER>s\<USER>\src\my-stuff\angular-seed\tools\tasks\seed
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.assets.dev
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.assets.prod
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.bundle.rxjs
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.bundles.app.aot
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.bundles.app.rollup.aot
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.bundles.app
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.bundles
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.docs
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.html_css
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.index.dev
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.index.prod
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.js.dev
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.js.e2e
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.js.prod.aot
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.js.prod.rollup.aot
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.js.prod
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.js.test
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\build.tools
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\check.tools
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\check.versions
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\clean.all
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\clean.coverage
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\clean.dev
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\clean.e2e
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\clean.prod
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\clean.tools
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\clear.files
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\compile.ahead.prod
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\copy.prod.rollup.aot
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\copy.prod
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\e2e
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\generate.manifest
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\i18n.build
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\i18n.merge
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\karma.run
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\karma.run.without_coverage
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\karma.run.with_coverage
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\karma.watch
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\minify.bundles
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\minify.index
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\noop
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\print.banner
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\serve.coverage
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\serve.coverage.watch
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\serve.docs
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\server.prod
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\server.start
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\start.deving
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\sw.manifest.static
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\test.watch
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\transpile.bundles.rollup.aot
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\tslint
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\watch.dev
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\watch.e2e
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\watch.test
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\seed\webdriver
[15:17:54] Loading tasks folder C:\<USER>s\<USER>\src\my-stuff\angular-seed\tools\tasks\project
[15:17:54] Registering task ~\src\my-stuff\angular-seed\tools\tasks\project\sample.task
[15:17:54] Using gulpfile ~\src\my-stuff\angular-seed\gulpfile.ts
[15:17:54] Starting 'build.bundle.rxjs'...
[15:18:05] Finished 'build.bundle.rxjs' after 12 s
npm WARN @angular/compiler-cli@4.2.6 requires a peer of typescript@^2.0.2 but none was installed.
npm WARN @angular/tsc-wrapped@4.2.6 requires a peer of typescript@^2.1.5 but none was installed.
npm WARN tsickle@0.21.6 requires a peer of typescript@^2.1.0 but none was installed.
npm WARN gulp-typescript@3.1.7 requires a peer of typescript@~2.0.3 || >=2.0.0-dev || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev but none was installed.
npm WARN tslint@5.5.0 requires a peer of typescript@>=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev but none was installed.
npm WARN tsutils@2.6.0 requires a peer of typescript@>=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >= 2.4.0-dev || >= 2.5.0-dev || >= 2.6.0-dev but none was installed.

npm ERR! May not delete: C:\<USER>s\<USER>\src\my-stuff\angular-seed\node_modules\.bin

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Programs\<USER>@localhost\npm-cache\_logs\2017-07-14T21_18_18_363Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! angular-seed@1.0.0 postinstall: `gulp check.versions && gulp build.bundle.rxjs && npm prune && gulp webdriver && gulp print.banner`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-seed@1.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
zkat commented 7 years ago

guess I'll try this again. Probably not going to touch this this weekend 'cause I need a bit of a break, but thanks for putting together something else I can try <3 I'll take a look next week for sure

gforceg commented 7 years ago

I'm willing to bet this has something to do w/ McAfee OnAccess Scanner -- which is a requirement where I work. Never the less, the above works about 90% of the time in npm < npm5.2 - now I'm only having success about 10% of the time.

It seems like it's trying to scan or unlink a file that does not exist anymore.

zkat commented 7 years ago

@gforceg I suspect your specific issue is a bit different from OP but it all seems to be in the same category.

One reason why npm@>=5.1.0 might be more prone to this is because npm started parallelizing installations in npm@5.1.0. So now there's 4-8 processes all hitting the filesystem and McAfee wants to cry.

gforceg commented 7 years ago

@zkat you're probably right. Now, I haven't run into this particular issue w/ yarn and I believe yarn also installs packages in parallel. Are there any flags I can pass to limit / prevent parallel installations?

e.g., npm i -j 2 or npm i --sync

(I much prefer npm over yarn for many reasons: publishing via npm is much cleaner thanks to .npmignore and npm has so much more CLI functionality.)

kylelamse commented 7 years ago

@zkat @gforceg I am running into this issue on my work computer which does indeed have McAfee installed. Edit: removed gist

zkat commented 7 years ago

@gforceg idk. last I checked, yarn was still doing copies on a single thread, but that may have changed. There's also (currently) no mechanism for controlling npm's parallelism besides patching lib/install/actions/extract.js to try it out.

What surprises me about stuff like this is that we're using https://npm.im/graceful-fs to handle weird Windows filesystem behavior like this. Perhaps graceful-fs is missing something, or for some reason, graceful-fs isn't being used by the tar extractor, or something. I wish this error had an actual stack trace, 'cause I've no idea where it's actually coming from rn.

Are you able to at least ignore a path, with your McAfee install?

gforceg commented 7 years ago

@zkat

It seems like yarn may have similar issues.

Thanks for referencing that file. I'm going to take a look at that. 🤓

Are you able to at least ignore a path, with your McAfee install?

I wish. IMHO that's the real solution. I never have these sort of issues in Fedora. 🙄

marcins commented 7 years ago

Interestingly we weren't seeing this issue when we first went from npm 5.0.3 to 5.1.0, however we recently did some work that involved adding approximately 20-30 packages to package.json (we consolidated multiple package.json files in our repo - long story) and since then we have been seeing this error in our CI builds that run on Windows. We will probably have to revert to npm 5.0.3 for now as well :(

cchamberlain commented 7 years ago

Also getting this issue on 5.2.0 / 5.3.0 but didn't notice on 5.0.3.

I'm noticing Windows Defender (MsMpEng.exe) jumping up to ~30%+ CPU usage during the install.

Workaround for me in the short-term is to use npm i --no-optional which bypasses fsevents altogether and never triggers the error. Wish there was a config option to always use --no-optional. 😿

One thing that seems a bit odd is if I delete package-lock.json and node_modules, then run npm i --no-optional I get a package-lock.json without fsevents throughout, yet it still attempts to install it anyways on successive runs of npm i.

gforceg commented 7 years ago

I haven't had a chance to mess w/ forcing sync yet. Will try this afternoon.

Off topic: package-lock.json behaves weirdly for me too. In 5.0.3 when I remove my node_modules directory and say 'npm install' some of my dependencies are not installed unless I delete package-lock.json and try again.

cchamberlain commented 7 years ago

@gforceg - re: the package-lock.json issue - are you sure the original package-lock.json (that you deleted) had the missing packages specified in it? My understanding is if the package-lock.json exists, it pretty much ignores package.json dependencies.

My debugging strategy for this is the following (replace react with your missing package):

DJviolin commented 7 years ago

Just to clarify the issue on Windows 10.

Windows 10 version: v10.0.15063 Node version: v8.1.4 NPM version: v5.0.3 (install works) NPM version: v5.3.0 and v5.2.0 (install NOT works)

I run everything from admin elevated command line.

Globally installed packages:

$ npm list -g --depth=0
C:\Users\User\AppData\Roaming\npm
+-- node-gyp@3.6.2
`-- npm-windows-upgrade@4.0.1

Local package.json dependencies:

  "dependencies": {
    "ar.js": "git+ssh://git@github.com/jeromeetienne/AR.js.git#master",
    "jsartoolkit": "git+ssh://git@github.com/artoolkit/jsartoolkit5.git#master",
    "three": "git+ssh://git@github.com/mrdoob/three.js.git#dev"
  },
  "devDependencies": {
    "babel-polyfill": "6.23.0",
    "babel-preset-es2017-node7": "0.5.2",
    "babel-register": "6.24.1",
    "gulp": "github:gulpjs/gulp#4.0",
    "gulp-clean-css": "3.7.0",
    "gulp-download": "0.0.1",
    "gulp-live-server": "0.0.31",
    "gulp-rename": "1.2.2",
    "gulp-replace": "0.6.1",
    "gulp-stylus": "2.6.0",
    "gulp-uglify": "3.0.0",
    "http-server": "0.10.0",
    "webpack": "3.3.0"
  },
  "optionalDependencies": {
    "babel-eslint": "7.2.3",
    "eslint": "4.2.0",
    "eslint-config-airbnb-base": "11.2.0",
    "eslint-plugin-babel": "4.1.1",
    "eslint-plugin-import": "2.7.0",
    "stylus": "0.54.5"
  }

With NPM version 5.3.0 and 5.2.0, I'm getting fsevents error:

$ npm install

> uglifyjs-webpack-plugin@0.4.6 postinstall D:\www\ar\magyarkert\node_modules\uglifyjs-webpack-plugin
> node lib/post_install.js

npm ERR! path D:\www\ar\magyarkert\node_modules\fsevents\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir 'D:\www\ar\magyarkert\node_modules\fsevents\node_modules'
npm ERR!  { Error: EPERM: operation not permitted, scandir 'D:\www\ar\magyarkert\node_modules\fsevents\node_modules'
npm ERR!   stack: 'Error: EPERM: operation not permitted, scandir \'D:\\www\\ar\\magyarkert\\node_modules\\fsevents\\node_modules\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'scandir',
npm ERR!   path: 'D:\\www\\ar\\magyarkert\\node_modules\\fsevents\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2017-07-19T15_23_24_369Z-debug.log

The log file: 2017-07-19T15_23_24_369Z-debug.log.txt

Where is the halt of execution doesn't matter in the log file, because if I uncommenting the webpack, than it will happen at another dependency.

I reverted back to NPM version 5.0.3 and it installs without problem:

$ npm install

> fsevents@1.1.2 install D:\www\ar\magyarkert\node_modules\fsevents
> node install

> uglifyjs-webpack-plugin@0.4.6 postinstall D:\www\ar\magyarkert\node_modules\uglifyjs-webpack-plugin
> node lib/post_install.js

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN eslint-config-airbnb-base@11.2.0 requires a peer of eslint@^3.19.0 but none was installed.
npm WARN ar-magyarkert@1.0.0 No repository field.
npm WARN ar-magyarkert@1.0.0 No license field.

added 838 packages in 85.087s

I hope it helps.

EDIT:

My antivirus softwares are Windows Defender and Malwarebytes.

lucastheisen commented 7 years ago

I'll add one more. In my case:

OS: Microsoft Windows [Version 10.0.14393] (Anniversary Edition) Node: 8.2.1 NPM: 5.3.0 A/V: Symantec Endpoint Protection (Enterprise)

npm ERR! path C:\Users\ltheisen\git\caasd-event-analyzer-parent\event-analyzer-web2\node_modules\fsevents\node_modules\dashdash\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir 'C:\Users\ltheisen\git\caasd-event-analyzer-parent\event-analyzer-web2\node_modules\fsevents\node_modules\dashdash\node
'
npm ERR!  { Error: EPERM: operation not permitted, scandir 'C:\Users\ltheisen\git\caasd-event-analyzer-parent\event-analyzer-web2\node_modules\fsevents\node_modules\dashdash\n
les'
npm ERR!   stack: 'Error: EPERM: operation not permitted, scandir \'C:\\Users\\ltheisen\\git\\caasd-event-analyzer-parent\\event-analyzer-web2\\node_modules\\fsevents\\node_mo
ashdash\\node_modules\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'scandir',
npm ERR!   path: 'C:\\Users\\ltheisen\\git\\caasd-event-analyzer-parent\\event-analyzer-web2\\node_modules\\fsevents\\node_modules\\dashdash\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ltheisen\AppData\Roaming\npm-cache\_logs\2017-07-25T21_09_00_506Z-debug.log

Dropping back to npm 5.0.3 works for now...

nejsimon commented 7 years ago

I have exactly the same problem with node 6, npm 5.3 on win7 64 bit. A downgrading to 5.0.4 fixed it for now.

elvirdolic commented 7 years ago

We have the same issue on windows server 2012. downgrade to 5.0.3 helps.

UnKnoWn-Consortium commented 7 years ago

Encountered the exact same issue after upgrading to the bleeding edge Node 8.2.1 and NPM 5.3.0 on Windows 7. Similarly solved by downgrading NPM but to 5.2.0.

caesay commented 7 years ago

Exact same issue here:

OS: Windows 10 Anniversary Node: 8.2.1 NPM: 5.3.0 A/V: Trend Micro OfficeScan

dfederm commented 7 years ago

Similar issue here. My scenario's a little interesting though, and I did find a mitigation.

EDIT: The mitigation was just luck. I still see this from time to time.

OS: Win 10 Node: 6.10.3 NPM: 5.3.0 A/V: Windows Defender

I use VSTS to do my CI/CD builds, and I happen to use my own machine for my build agent so long story short I effectively end up running a "clean" build elsewhere on my machine at those times (but still as my user, not as Administrator), and as part of that build is an npm install.

While developing everything works just fine, however when the VSTS build agent ran npm install, I ended up with the follow error (including just the last couple handfuls of lines for brevity):

13363 info lifecycle tslint@5.5.0~postinstall: tslint@5.5.0
13364 silly postinstall typescript@2.4.1
13365 info lifecycle typescript@2.4.1~postinstall: typescript@2.4.1
13366 silly postinstall zone.js@0.8.13
13367 info lifecycle zone.js@0.8.13~postinstall: zone.js@0.8.13
13368 verbose unlock done using C:\Users\David\AppData\Roaming\npm-cache\_locks\staging-7810e60c30115527.lock for c:\Agent\_work\1\s\src\Website\node_modules\.staging
13369 verbose stack Error: EPERM: operation not permitted, scandir 'c:\Agent\_work\1\s\src\Website\node_modules\fsevents\node_modules\tar-pack\node_modules'
13369 verbose stack     at Error (native)
13370 verbose cwd c:\Agent\_work\1\s\src\Website
13371 verbose Windows_NT 10.0.14393
13372 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\David\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
13373 verbose node v6.10.3
13374 verbose npm  v5.3.0
13375 error path c:\Agent\_work\1\s\src\Website\node_modules\fsevents\node_modules\tar-pack\node_modules
13376 error code EPERM
13377 error errno -4048
13378 error syscall scandir
13379 error Error: EPERM: operation not permitted, scandir 'c:\Agent\_work\1\s\src\Website\node_modules\fsevents\node_modules\tar-pack\node_modules'
13379 error     at Error (native)
13379 error  { Error: EPERM: operation not permitted, scandir 'c:\Agent\_work\1\s\src\Website\node_modules\fsevents\node_modules\tar-pack\node_modules'
13379 error     at Error (native)
13379 error   stack: 'Error: EPERM: operation not permitted, scandir \'c:\\Agent\\_work\\1\\s\\src\\Website\\node_modules\\fsevents\\node_modules\\tar-pack\\node_modules\'\n    at Error (native)',
13379 error   errno: -4048,
13379 error   code: 'EPERM',
13379 error   syscall: 'scandir',
13379 error   path: 'c:\\Agent\\_work\\1\\s\\src\\Website\\node_modules\\fsevents\\node_modules\\tar-pack\\node_modules' }
13380 error Please try running this command again as root/Administrator.
13381 verbose exit [ -4048, true ]

I was seeing this consistently in the VSTS build agent. When perusing this thread though I decided to try a npm cache verify (not as Administrator btw) and what do you know, the next build from my build agent worked.

In case it matters, here was the output from the npm cache verify:

Cache verified and compressed (~\AppData\Roaming\npm-cache\_cacache):
Content verified: 1869 (70911958 bytes)
Content garbage-collected: 205 (5655932 bytes)
Index entries: 3330
Finished in 6.363s

Also, here's the same logs (slightly less verbose though since they were successful) after doing the npm cache verify:

2017-08-06T04:37:19.4510349Z npm info lifecycle tslint@5.5.0~postinstall: tslint@5.5.0
2017-08-06T04:37:19.4510349Z npm info lifecycle typescript@2.4.1~postinstall: typescript@2.4.1
2017-08-06T04:37:19.4510349Z npm info lifecycle zone.js@0.8.13~postinstall: zone.js@0.8.13
2017-08-06T04:37:19.4865893Z npm verb unlock done using C:\Users\David\AppData\Roaming\npm-cache\_locks\staging-7810e60c30115527.lock for c:\Agent\_work\1\s\src\Website\node_modules\.staging
2017-08-06T04:37:20.7337349Z npm info linkStuff clicker-heroes-tracker-website@0.0.0
2017-08-06T04:37:20.7337349Z npm verb linkBins clicker-heroes-tracker-website@0.0.0
2017-08-06T04:37:20.7337349Z npm verb linkMans clicker-heroes-tracker-website@0.0.0
2017-08-06T04:37:20.7342357Z npm info lifecycle clicker-heroes-tracker-website@0.0.0~install: clicker-heroes-tracker-website@0.0.0
2017-08-06T04:37:20.7342357Z npm info lifecycle clicker-heroes-tracker-website@0.0.0~postinstall: clicker-heroes-tracker-website@0.0.0
2017-08-06T04:37:20.7357385Z npm info lifecycle clicker-heroes-tracker-website@0.0.0~prepublish: clicker-heroes-tracker-website@0.0.0
2017-08-06T04:37:20.7357385Z npm info lifecycle clicker-heroes-tracker-website@0.0.0~prepare: clicker-heroes-tracker-website@0.0.0
2017-08-06T04:37:21.0056530Z npm verb saving []
2017-08-06T04:37:21.0126640Z npm info lifecycle undefined~preshrinkwrap: undefined
2017-08-06T04:37:21.0301912Z npm info lifecycle undefined~shrinkwrap: undefined
2017-08-06T04:37:21.0434523Z npm info lifecycle undefined~postshrinkwrap: undefined
2017-08-06T04:37:21.0444538Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.1 (node_modules\fsevents):
2017-08-06T04:37:21.0449543Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
2017-08-06T04:37:21.0449543Z npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
2017-08-06T04:37:21.0449543Z npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
2017-08-06T04:37:21.0449543Z npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
2017-08-06T04:37:21.0449543Z npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
2017-08-06T04:37:21.0449543Z 
2017-08-06T04:37:21.0459561Z added 657 packages in 13.013s
2017-08-06T04:37:21.0489605Z npm verb exit [ 0, true ]
2017-08-06T04:37:21.0569728Z npm info ok

I'm actually considering as part of my build process to just do an npm cache verify before the npm install. It doesn't seem to take very long and seems to have fixed a few other issues in the past as well for me. IMHO that's just a mitigation and npm itself shouldn't get into bad states in the first place, ideally at least :).

JeffSkyrunner commented 7 years ago

Can anyone explain to a total noob how to revert to a previous version of npm and ran the ionic tutorials? :)

I'm having the same issues as above

egoroof commented 7 years ago

@JeffSkyrunner run in the command line (or whatever your shell): npm i -g npm@5.0.4. 5.0.4 shouldn't have the issue but you can specify other lower version.

JeffSkyrunner commented 7 years ago

@egoroof

Thanks. I can confirm that this works.

erlangparasu commented 7 years ago

thanks. i delete package-lock.json and worked :D

phawrylak commented 7 years ago

I have the same issue with npm@5.3.0 and Node.js@8.3.0 on Windows Server 2012 R2. I hope this will be fixed in next release, because it's really annoying.

monzol commented 7 years ago

I get the same fsevents related error when trying to create a new Angular project by running ng new my-app Then simply entering the my-app directory and running npm install will complete the job without error. My setup: angular/cli: 1.1.1 node: 7.8.0 npm: 5.3.0 OS: Windows

brian428 commented 7 years ago

Same issue here. Just wanted to add: our corporate disk image does force us to have McAffee installed on our machines. And unfortunately, we can't modify the exclusions (they're set at the domain level).

The odd thing is that, as far as I can tell, this "operation not permitted" error at the end of npm install is the only thing causing problems. If this is actually due to McAffee in some way, it seems odd that only this one thing is failing.

kylelamse commented 7 years ago

@zkat any news on this?

goenkar commented 7 years ago

I am having the same issue. Re-running npm install again sometimes works. Everytime I run npm install, it kills my typescript link and I have to run "npm link typescript" again. I am working in a VM environment and don't have anti-virus in the guest machine.

Windows Server 2012 R2 Node: v8.3.0 npm: 5.3

I was unable to downgrade to a previous version as I get a "Refusing to delete C:\Node\npm.cmd: is outside C:\Node\node_modules\npm and not a link" error.

lexkrstn commented 7 years ago

The same here.

Windows 10 Node: v8.4.0 Npm: v5.3.0

I've tried to use npm-windows-upgrade with PowerShell to downgrade the npm only but it seems not work. The easiest way I've found is to downgrade Node itself via $ nvm install 8.1.4.

sudheerkaushik commented 7 years ago

@egoroof solution worked for me. I had to fall back to npm 5.

kylelamse commented 7 years ago

The solution is to just use yarn lol

avbentem commented 7 years ago

@UnKnoWn-Consortium wrote:

Similarly solved by downgrading NPM but to 5.2.0.

For me, 5.2.0 did not work, but downgrade to npm install -g npm@5.0.4 (like @nejsimon wrote) fixed it for me. (Node 8.4.0; Windows 7; Trend Micro Office Scan, Real-time Scan and Smart Scan; yeah our IT department likes their virus scanners...)

doberkofler commented 7 years ago

@zkat I opened a separate issue #17747 in July that according to @marcins might be related to this one. It seems as if this issue still cannot be reproduced and maybe my latest finding might help to do so. In my experience, the problem happens in a reproducible way. I discovered that after cleaning the cache the first installation works as expected but when later installing the same dependencies in another project the error arises. In my opinion and given the fact that the problems seems to happen with optional dependencies, this suggests a problem in the resolution/caching of the resolved optional dependencies.

JaimeStill commented 7 years ago

One issue that I found that was causing these sort of errors is as follows:

With an ASP.NET Core project running in Visual Studio trying to run the npm install command directly from the command line.

If I close out of Visual Studio, then run the command, it works just fine. I'm not sure if there is some sort of issue associated with NPM attempting to execute while Visual Studio is also attempting to install the modules as well.

filipesilva commented 7 years ago

@pepone your workaround of using --no-optional makes sense. Do you find it working?

pepone commented 7 years ago

@filipesilva This issue was affecting our CI builds but was not happening all the time. We will soon see if that worked.

marcins commented 7 years ago

@zkat I've been able to reproduce this very intermittently in my Windows VM. I setup a mimimal test case - a package.json/package-lock.json with just fsevents in it. Since it's optional and doesn't install on Windows I had to generate the package-lock.json on my Mac.

To try and help things along I have VSCode open with the node_modules directory open (since some people above refer to concurrent access as the issue).

I ran npm i --no-save over and over (npm v5.3.0) - the --no-save to prevent it being removed from package-lock.json.

Maybe about 1 in 10 times I can get an error. Interestingly since the only thing is fsevents (and it's optional) the node_modules dir is removed at the end of the process and I mostly get an EPERM error relating to this as well, even though the directory does get removed. Could be the same root cause though.

C:\temp>npm i --no-save
npm ERR! path C:\temp\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rmdir
npm ERR! Error: EPERM: operation not permitted, rmdir 'C:\temp\node_modules'
npm ERR!  { Error: EPERM: operation not permitted, rmdir 'C:\temp\node_modules'
npm ERR!   stack: 'Error: EPERM: operation not permitted, rmdir \'C:\\temp\\node_modules\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rmdir',
npm ERR!   path: 'C:\\temp\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\mszcz\AppData\Roaming\npm-cache\_logs\2017-08-29T01_47_46_340Z-debug.log

Since I was just getting that EPERM above, I started doing npm i --no-save css-loader instead (a package mentioned above). And was then able to repro the fsevents scandir error (still intermittently).

Hope that can help you to reproduce? If I get time maybe I'll look into writing a Node script that uses the NPM module directly and does an install in a loop to try and trigger it with the debugger connected. I don't have any familiarity with the npm codebase, so don't know how productive I'll be.

marcins commented 7 years ago

So I got a little bit further with this, I managed to get a rough script running that could reliably reproduce some sort of EPERM error, using the idea above (have a package-lock that only includes fsevents and repeatedly do an npm install).

I haven't been able to identify the root cause, however I was able to do a git bisect between 5.0.4 and 5.4.0 and identify the commit where the issue started occurring: 394436b098dcca2d252061f95c4eeb92c4a7027c

As far as I understand if the platform check fails the module is removed from node_modules - I think it's during this removal that the EPERM errors are occurring, I've seen them coming from different syscalls - but in my latest reproduction (on a real Windows machine) it was mostly from unlink (though I saw scandir like the above as well).

Not sure if any of that helps, if I get some free time I will try and get my repro script cleaned up a bit in the next few days and share it if that's going to help you to reproduce the issue.

I think this issue could occur with any optional package that's platform specific, but it might be exacerbated by the number of dependencies fsevents has, and how often it is a dependency itself.

greggb commented 7 years ago

Happening on my Ubuntu VM, so doesn't appear to just be a Windows issue.