Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

npm5 not working on the windows platform (Error: EPERM: operation not permitted...) #19004

Closed
2 of 13 tasks
doberkofler opened this issue Oct 30, 2017 · 23 comments
Closed
2 of 13 tasks
Labels

Comments

@doberkofler
Copy link

I'm opening this issue because:

  • npm is crashing.
  • npm is producing an incorrect install.
  • npm is doing something I don't understand.
  • Other (see below for feature requests):

What's going wrong?

npm 5 is not working at all on the windows platform (most likely because of optional dependencies)

How can the CLI team reproduce the problem?

Install webpack, then uninstall and try to install again always leads to this error as visible in the following output:

>npm --version
5.5.1

D:\MyDev\ljs_app\trunk\periscope\examples\bugs\>node --version
v8.8.1

D:\MyDev\ljs_app\trunk\periscope\examples\bugs\>npm cache clear --force
npm WARN using --force I sure hope you know what you are doing.

D:\MyDev\ljs_app\trunk\periscope\examples\bugs\>npm i

> uglifyjs-webpack-plugin@0.4.6 postinstall D:\MyDev\ljs_app\trunk\periscope\examples\bugs\npm\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 bug-report@1.0.0 No description
npm WARN bug-report@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
)

added 364 packages in 36.542s

D:\MyDev\ljs_app\trunk\periscope\examples\bugs\npm>npm uninstall webpack
npm WARN bug-report@1.0.0 No description
npm WARN bug-report@1.0.0 No repository field.

removed 249 packages in 8.236s

D:\MyDev\ljs_app\trunk\periscope\examples\bugs\npm>npm i webpack

> uglifyjs-webpack-plugin@0.4.6 postinstall D:\MyDev\ljs_app\trunk\periscope\examples\bugs\npm\node_modules\uglifyjs-webpack-plugin
> node lib/post_install.js

npm ERR! path D:\MyDev\ljs_app\trunk\periscope\examples\bugs\npm\node_modules\fsevents\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 'D:\MyDev\ljs_app\trunk\periscope\examples\bugs\npm\node_modules\fsevents\node_modules\getpass\node_module
s'
npm ERR!  { Error: EPERM: operation not permitted, lstat 'D:\MyDev\ljs_app\trunk\periscope\examples\bugs\npm\node_modules\fsevents\node_modules\getpass\node_mod
ules'
npm ERR!   stack: 'Error: EPERM: operation not permitted, lstat \'D:\\MyDev\\ljs_app\\trunk\\periscope\\examples\\bugs\\npm\\node_modules\\fsevents\\node_module
s\\getpass\\node_modules\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'lstat',
npm ERR!   path: 'D:\\MyDev\\ljs_app\\trunk\\periscope\\examples\\bugs\\npm\\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\doberkofler.LBITS\AppData\Roaming\npm-cache\_logs\2017-10-30T15_09_05_838Z-debug.log
{
  "name": "bug-report",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {}
}

supporting information:

  • npm -v prints: 5.5.1
  • node -v prints: 8.8.1
  • npm config get registry prints: http://registry.npmjs.org/
  • Windows, OS X/macOS, or Linux?: Windows 7
  • Network issues:
    • Geographic location where npm was run:
    • I use a proxy to connect to the npm registry.
    • I use a proxy to connect to the web.
    • I use a proxy when downloading Git repos.
    • I access the npm registry via a VPN
    • I don't use a proxy, but have limited or unreliable internet access.
  • Container:
    • I develop using Vagrant on Windows.
    • I develop using Vagrant on OS X or Linux.
    • I develop / deploy using Docker.
    • I deploy to a PaaS (Triton, Heroku).
@ewhitmore
Copy link

ewhitmore commented Oct 30, 2017

I am also experiencing this issue on windows. I tried different NPM versions from 5.0.4 to current without success. I tried with the node 6 LTS versions and with node 8 versions.

@DJviolin
Copy link

This one solved the #17671 error for me:

$ npm i -f <package>
# or
$ npm install --force <package>

Maybe related here. fsevents has missing dependencies without forced install since v5.0.4. Check the log files if it's complaining about missing fsevents dependencies and check it's folder also.

@ewhitmore
Copy link

The npm i -f <package> does work BUT the cost is that you loose the ability to cache packages which increases build time. Great workaround, not a great solution...

@matthiku
Copy link

matthiku commented Nov 6, 2017

I just installed a fresh
node v8.9.0
npm v5.5.1
on Windows 10.
I am using Git Bash and installed vue-cli, then created a new project using
vue-init webpack-simple stocktrader, then did
npm install and
npm run dev.
I broke out of the dev server (hit Ctrl-C twice!) and tried to install vuex:
npm install --save-dev vuex and got this error:

npm ERR! path C:\laragon\www\stockTrader\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:\laragon\www\stockTrader\node_modules\fsevents\node_modules'
npm ERR!  { Error: EPERM: operation not permitted, scandir 'C:\laragon\www\stockTrader\node_modules\fsevents\node_modules'
npm ERR!   stack: 'Error: EPERM: operation not permitted, scandir \'C:\\laragon\\www\\stockTrader\\node_modules\\fsevents\\node_modules\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'scandir',
npm ERR!   path: 'C:\\laragon\\www\\stockTrader\\node_modules\\fsevents\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

Then I did a npm cache verify and tried to install vuex again, and bingo! it worked.

@corvinrok
Copy link

This issue has now become the main problem with node since 7.10.1.

Because of this, our project can't move past node 7.10.1, even though we would have liked to move to all latest versions of node 8 (and later to node 9..)..

Has NPM decided that they will not fix this issue? It's hard to believe since anyone using Windows and installing a native dependency (from node-sass to xml libraries and more) will run into this issue.

We are considering moving to yarn because of this since it has killed our use of npm.

@DJviolin
Copy link

DJviolin commented Nov 6, 2017

For me, Yarn doesn't even install fsevents on Windows, even if I used --force or npm cache verify.

Throwing error because win32 is an unsupported platform.

@matthiku
Copy link

matthiku commented Nov 6, 2017

fsevents is only designed for iOS anyway. So that's fine and as designed.
But what annoys me is that you always get a warning about it each time you install a package about it.

@Laughing-Vergil
Copy link

Laughing-Vergil commented Nov 10, 2017

So it is pretty clear that what is happening is that the cache is being corrupted somehow on installation. It is a pretty minor corruption, since npm cache verify will fix it, and it is cache related since --force allows the install to work.

Now if someone could simply identify what is being changed when the cache is verified, we would be much closer to identifying the root issue.

@SiggeSeb
Copy link

Apparently @Cito has a solution at the end of this error but the solution has yet to be merged to master

@doberkofler
Copy link
Author

@SiggeSeb I know, and it works like a charm.

@uglycoyote
Copy link

I'm getting this trying to use angular-cli, under Windows 10, trying to do "ng new myAppName"
node v8.9.1, npm v5.3.0.

running as administrator as suggested in the error message does not solve it.
npm cache clean --force does not solve it

npm ERR! path D:\temp\myAppName\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:\temp\myAppName\node_modules\fsevents\node_modules'
npm ERR!  { Error: EPERM: operation not permitted, scandir 'D:\temp\myAppName\node_modules\fsevents\node_modules'
npm ERR!   stack: 'Error: EPERM: operation not permitted, scandir \'D:\\temp\\myAppName\\node_modules\\fsevents\\node_modules\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'scandir',
npm ERR!   path: 'D:\\temp\\myAppName\\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\admin\AppData\Roaming\npm-cache\_logs\2017-11-15T19_56_23_620Z-debug.log

@puttuo
Copy link

puttuo commented Nov 20, 2017

In Windows, you can try to start the command line using "Run as administrator". This option may solve the problem.

@ryanbuening
Copy link

@puttuo "Run as administrator" didn't solve the problem for me.

@EwertonDutra
Copy link

For me, every time I run a command it gives an error. Then the second time it works out.
Ex: npm i --save-dev webpack@1.14.0 webpack-dev-server@1.16.2

1 st wrong
Right 2

I use windows 7 x64
npm --v 5.5.1
CMD: cmder

@JustasKuizinas
Copy link

JustasKuizinas commented Nov 21, 2017

npm install -g yarn

@matthiku
Copy link

matthiku commented Dec 1, 2017

This is just an intermittent issue (at least in my case), probably caused by some syncing issue in Windows.
Just repeat the last command and everything is fine!!

clipboarder 2017 12 01-002

And it's always that annoying 'fsevents' package which is causing this issue!

@jacobq
Copy link

jacobq commented Dec 4, 2017

Does anyone have a solution for this other than downgrading or switching to yarn? My situation is quite similar to those described by others in this thread and the previous one. One thing I noticed though was that it seems to be related to packages that are platform-dependent. For example, I have an electron app that can be packaged to install on Windows, Linux, or Mac OS, and on Windows npm will correctly skip the linux & mac stuff, but then this scandir/EPERM error comes up and lists one of the modules for a different platform (which is not installed and not supposed to be installed!).

@doberkofler
Copy link
Author

5.6.0 solves this problem!

@uglycoyote
Copy link

uglycoyote commented Dec 4, 2017

@doberkofler can you a be a bit more specific about what problem was solved and when it was solved? The release notes do not mention this bug specifically and nothing in the 5.6.0 notes appears directly related.

I did notice that the 5.1.0 release notes mention:

394436b #17552 Make refresh-package-json re-verify the package platform. This fixes an issue most notably experienced by Windows users using create-react-app where fsevents would not short-circuit and cause a crash during its otherwise-skipped native build phase. (@zkat)

This seemed of interested to me: I got involved with this thread because I'm getting EPERM errors with fsevents under Windows. However I was still getting those problems on npm 5.3.0.

Given that a wide variety of users seem to be getting these EPERM errors in a wide variety of situations, It seems to me like a major widespread problem that deserves mention in the release notes if it was fixed. Since it's not in the release notes and there's not much detail in your issue-close comment I'm feeling skeptical.

@cdanielsen
Copy link

@uglycoyote I think @doberkofler is referring to the first item in the 5.6.0 notes

bc263c3fd #19054 Fully cross-platform package-lock.json. Installing a failing optional dependency on one platform no longer removes it from the dependency tree, meaning that package-lock.json should now be generated consistently across platforms! 🎉 (@iarna)

#19054 is the currently approved/merged fix for this issue

@MikaelLambert
Copy link

@doberkofler Upgrading to 5.6.0 worked for me, thanks.

@fromorbonia
Copy link

I had a similar problem with an Azure automated Git deployment using 5.3.0, switching to to 5.6.0 worked. Thanks

@EBMike
Copy link

EBMike commented Feb 12, 2018

@doberkofler This issue is still happening in 5.6 (even running as Administrator, only fix i've found so far is setting permissions on the node_modules folder to "Everyone" will full perms)...
Error: EPERM: operation not permitted, rename

UPDATE:
noticed this in another issue... "It looks like a background process is preventing npm from doing the job"... I had Visual Studio 2017 opened, so I closed that, then npm installed and it worked.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests