node-sass: EINVAL: invalid argument, open '/code/node_modules/node-sass/package.json'
Failure upon running the npm install command within a freshly cloned project.
- NPM version (
npm -v):6.4.1 - Node version (
node -v):v8.12.0 - Node Process (
node -p process.versions):
{ http_parser: '2.8.0',
node: '8.12.0',
v8: '6.2.414.66',
uv: '1.19.2',
zlib: '1.2.11',
ares: '1.10.1-DEV',
modules: '57',
nghttp2: '1.32.0',
napi: '3',
openssl: '1.0.2p',
icu: '60.1',
unicode: '10.0',
cldr: '32.0',
tz: '2017c' }
- Node Platform (
node -p process.platform):linux - Node architecture (
node -p process.arch):x64 - node-sass version (
node -p "require('node-sass').info"): Not applicable (never successfully installed.) - npm node-sass versions (
npm ls node-sassafter trying to runnpm install):
root:/code# npm ls node-sass
my_project@0.0.0 /code
`-- @angular-devkit/build-angular@0.10.2
`-- UNMET DEPENDENCY node-sass@4.9.3
npm ERR! missing: node-sass@4.9.3, required by @angular-devkit/build-angular@0.10.2
My experience is as follows (I can post additional info of my project, if required.)
Side-notes:
node-sassfails to install within my ubuntu-16.04 based docker image (microsoft/vsts-agent) and this environment is what this issue concerns.node-sasssuccessfully installs on my windows host machine. My windows environment has same major versions of my docker container’s environment (node + npm) and the project’s source is the same on windows as what I am trying to developer against in the docker container.
root:/code# npm install
npm WARN (deprecated warnings)
> uws@9.14.0 install /code/node_modules/uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0
> node-sass@4.9.3 install /code/node_modules/node-sass
> node scripts/install.js
fs.js:646
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EINVAL: invalid argument, open '/code/node_modules/node-sass/package.json'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at Object.Module._extensions..json (module.js:670:20)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/code/node_modules/node-sass/lib/extensions.js:7:9)
at Module._compile (module.js:653:30)
npm WARN (rollback warnings here)
npm WARN (peer dependency warnings here)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.9.3 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.9.3 install 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! /root/.npm/_logs/2018-10-23T17_41_19_761Z-debug.log
root:/code#
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 18 (2 by maintainers)
I’m aware this issue has been closed, but it’s still a problem for me.
It appears that this has been closed under the premise that this is a problem with npm, node, docker, windows, or some other utility. Have issue(s) been filed in the appropriate repositories so that I can track them? Can we reference those issues so others, like me, that stumble here can find the appropriate issues?
In fact, @gwenl, the accepted answer here is what is now working for me: https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
It seems for me that the synchronization between my Windows host and Linux container was mixing a lot up.
Hello,
I have a Windows 10 with docker and I use the following workaround. Into the docker, in my home I create a directory, for example <project name>/node_modules. Them in my mapped directory within windows and linux(into the docker) I make a symbolic link within the directory I created before an “node_modules”. Something like ln -s <src> <dest> ln -s /home/my_project/node_modules /var/www/html/my_project/node_modules
Them, into my project I call the npm install
With this solution, the node-sass install with no problem.
I’m not an expert but I think the problem was the mapping within the windows and linux and the way that npm installs with links this package.
Best regards
I have the same error in the same environment (@METACEO : I guess you run docker on Windows ?), and indeed it seems to be related to how the directories in the container are mapped on the host. Maybe some magic with symlinks that the host FS doesn’t understand ? If I move package.json to another directory within the container that is not mapped on the host (say /tmp/), the npm install just goes fine.
It used to work quite recently so I guess some dependency changed its behavior in the meantime.
It seems there is no such problem with yarn, so I’ll temporarily switch away from npm.
I have exactly the same issue that I can reproduce as follow:
Context
Windows 10, WSL
Minimal project
Only one
package.jsonFailure on
npm installI have added a
.npmrcwithrollback=falseand I can confirm thatpackage.jsonis readable:I had the extact issue yesterday. I have a windows 10 environment with docker running. I created an SPFX project using yeoman and after the scaffolding it gave out the same error.
I run the command
yarnand it all went well.