docker-node
docker-node copied to clipboard
Command "npm install -g" causes "ERR! Cannot read property 'path' of null"
attempting to enhance this image by installing Elm globally but encountering issues. It would appear that the installation process for npm
is user 500
and owns and restricts access to /usr/local/lib/node_modules
by default. Seems like an unnecessary constraint to impose on an already isolated environment.
Investigation revealed:
4337 error Linux 4.4.0-21-generic
4338 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "elm"
4339 error node v7.8.0
4340 error npm v4.2.0
4341 error path /usr/local/lib/node_modules
4342 error code EACCES
4343 error errno -13
4344 error syscall access
4345 error Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
4345 error { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
4345 error errno: -13,
4345 error code: 'EACCES',
4345 error syscall: 'access',
4345 error path: '/usr/local/lib/node_modules' }
4346 error Please try running this command again as root/Administrator.
4347 verbose exit [ -13, true ]
and
ls -al /usr/local/lib/node_modules
total 12
drwxrwxr-x 3 500 500 4096 Mar 29 01:27 .
drwxrwxr-x 4 500 500 4096 Mar 29 01:27 ..
drwxrwxr-x 11 500 500 4096 Mar 29 01:27 npm
where
id -nu 500
id: 500: no such user
I think this is due to run npm as root. You should run it as the node
user
I can't seem to get this to work either. I am trying with this dockerfile:
FROM node:latest
USER node
RUN npm install -g elm
CMD ['elm', '--version']
However I still get this error:
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
Am I using the USER
directive incorrectly?
Note: I am able to get it working by overriding the npm install dir:
FROM node:latest
USER node
RUN mkdir ~/.npm-global
ENV NPM_CONFIG_PREFIX=~/.npm-global
RUN npm install -g elm
CMD ['elm', '--version']
Hmm, odd. Should we make node
the owner of /usr/local
? or at least /usr/local/lib/node_modules
?
There is https://github.com/nodejs/docker-node/issues/479#issuecomment-319447486. PR welcome!
Yeah, it is definitely awkward. @SimenB does this folder even exist before running npm to begin with?
Ooooh it does!!!
Yup.
$ docker run node:latest ls -la /usr/local/lib/node_modules/npm
total 192
drwxrwxr-x 11 500 500 4096 Jul 20 20:59 .
drwxrwxr-x 3 500 500 4096 Jul 20 20:59 ..
drwxrwxr-x 2 500 500 4096 Jul 20 20:59 .github
-rw-rw-r-- 1 500 500 2813 Jul 19 15:54 .mailmap
-rw-rw-r-- 1 500 500 539 Jul 11 00:43 .npmignore
-rw-rw-r-- 1 500 500 1297 Jul 19 15:54 .travis.yml
-rw-rw-r-- 1 500 500 18878 Jul 19 15:54 AUTHORS
-rw-rw-r-- 1 500 500 51191 Jul 19 15:54 CHANGELOG.md
-rw-rw-r-- 1 500 500 4474 Jul 19 15:54 CONTRIBUTING.md
-rw-rw-r-- 1 500 500 9742 May 29 11:46 LICENSE
-rw-rw-r-- 1 500 500 5287 Jul 19 15:54 Makefile
-rw-rw-r-- 1 500 500 4719 Jul 19 15:54 README.md
-rw-rw-r-- 1 500 500 7997 Jul 19 15:54 TROUBLESHOOTING.md
-rw-rw-r-- 1 500 500 959 Jul 19 15:54 appveyor.yml
drwxrwxr-x 3 500 500 4096 Jul 20 20:59 bin
drwxrwxr-x 2 500 500 4096 Jul 20 20:59 changelogs
-rwxrwxr-x 1 500 500 521 May 29 11:46 configure
drwxrwxr-x 6 500 500 4096 Jul 20 20:59 doc
drwxrwxr-x 4 500 500 4096 Jul 20 20:59 html
drwxrwxr-x 8 500 500 4096 Jul 20 20:59 lib
-rw-rw-r-- 1 500 500 156 May 29 11:46 make.bat
drwxrwxr-x 5 500 500 4096 Jul 20 20:59 man
drwxrwxr-x 99 500 500 4096 Jul 20 20:59 node_modules
-rw-rw-r-- 1 500 500 6208 Jul 19 15:54 package.json
drwxrwxr-x 2 500 500 4096 Jul 20 20:59 scripts
You beat me to it!!! I was going to post the same!
Doing chown -R node:node /usr/local/lib/node_modules
kinda works, but then it fails when trying to link binaries into /usr/local/bin/
.
So either we should just set a npm prefix for the node-user somehow (.npmrc in its $HOME
?) or document that consumers have to in order to use global installs as non-root
Can we configure the bin
folder npm uses to point to a folder that the node
user owns and add that one to PATH
?
That's the prefix option.
See https://docs.npmjs.com/files/folders
@SimenB we can move the whole global dependencies to the user space with the prefix or we can figure a way to make linked binary work in /usr/local
. Maybe this deserves it's own issue.
we can move the whole global dependencies to the user space with the prefix or we can figure a way to make linked binary work in
/usr/local
.
Setting NPM_CONFIG_PREFIX
somehow for the node
user makes sense to me. If it's seen as a breaking change, we should at least document that.
Maybe this deserves it's own issue.
Sure.
I like the prefix better as well but the other option is potentially less disruptive
I am unable to install protractor globally. facing permission issue even though i am installing as root Missing write access to /usr/local/lib/node_modules npm ERR! path /usr/local/lib/node_modules Please help me Thanks in advance
bonjour a tous, moi je pense avoir le même problème, je débute en node.js, et je voulais installer express-generator ( avec npm install express-generator -g) mais ça me donne toujours le même résultat (affiché en bas du message ) j'ai essayé avec sudo (sudo npm install express-generator -g) , j'arrive a l'installer mais quand j'utilise express myapp pour créer une application express ça m'affiche -bash: express: command not found,
si quelqu'un peux m'aider merci
path /Users/myname/.npm-packages/lib/node_modules/express-generator npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall access npm ERR! Error: EACCES: permission denied, access '/Users/myname/.npm-packages/lib/node_modules/express-generator' npm ERR! { [Error: EACCES: permission denied, access '/Users/myname/.npm-packages/lib/node_modules/express-generator'] npm ERR! stack: npm ERR! 'Error: EACCES: permission denied, access '/Users/myname/.npm-packages/lib/node_modules/express-generator'', npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: npm ERR! '/Users/myname/.npm-packages/lib/node_modules/express-generator' } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator (though this is not recommended).
npm ERR! A complete log of this run can be found in: npm ERR! /Users/myname/.npm/_logs/2018-08-14T13_20_55_520Z-debug.log
Les paths ci-haut semble être des paths de Mac OS. Utilisez-vous docker pour node?
merci pour votre réponse Laurent , aprés avoir regardé sur le net ce que veux dire docker, car ça me dis rien, je pense que je l'ai pas utlisé, et effectivement c'est des paths de Mac OS merci
We have no specific solution for this problem of rights?
The solution mentioned here works. https://github.com/nodejs/docker-node/issues/437#issuecomment-320993300
In addition, npm added the npx
command for running installed dependencies which significantly simplifies running globally installed modules.
It is part of documentation.
I was facing this issue while building the Angular 6 image with Docker (v18.09.0).
The Proxy variables of node and Docker environment were causing the problem. The solution is to reset httpProxy
variable value as told here: Docker doc. Also, set project specific .npmrc
like: gist and fix the npm
permission issue: gist
Finally, my Dockerfile
looks like:
FROM node:10.14.2-alpine
###
#Issue: 'Cannot read property 'startsWith' of null in npm install' error
#Reason: Proxy variables of node and Docker environment were causing the problem.
#Solution: Modify httpProxy variable value as told here: https://docs.docker.com/network/proxy/#configure-the-docker-client
# Also, set project specific .npmrc like : https://gist.github.com/nikhilbchilwant/7243ea4c6f35f28fb44376dac675d285
#RUN apk add tree
WORKDIR /home/node/aas-ui
#Fix for npm permission issue: https://github.com/angular/angular/blob/f8096d499324cf0961f092944bbaedd05364eea1/tools/ngcontainer/Dockerfile#L51
RUN mkdir /home/node/.npm-global \
&& npm config set prefix '/home/node/.npm-global' \
&& echo "export PATH=/home/node/.npm-global/bin:$PATH" >> /home/node/.profile
RUN source /home/node/.profile
RUN chown -R node $(npm config get prefix)
RUN chown -R node /home/node/aas-ui
USER node
COPY src ./src/
COPY e2e ./e2e/
COPY .angular-cli.json ./angular-cli.json
COPY protractor.conf.js ./protractor.conf.js
COPY karma.conf.js ./karma.conf.js
COPY tslint.json ./tslint.json
COPY package.json .
COPY angular.json .
COPY .npmrc .
RUN npm install --verbose
RUN npm build --verbose
I hope this helps someone.
Hi,
I am facing the same issue.
I am trying to install globally node-sass
in my Docker container and it fails with an EACCES
error.
node-sass
is using node-gyp
such as elm
. I tried to install react
globally and it works with no errors (see code snippets below).
/ # npm i -g react
+ [email protected]
added 7 packages from 3 contributors in 0.826s
/ # npm rm -g react
removed 7 packages in 0.15s
/ # npm i -g elm
/usr/local/bin/elm -> /usr/local/lib/node_modules/elm/bin/elm
> [email protected] install /usr/local/lib/node_modules/elm
> binwrap-install
ERR Error extracting https://github.com/elm/compiler/releases/download/0.19.0/binaries-for-linux.tar.gz - Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/elm/unpacked_bin'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `binwrap-install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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/2019-04-09T16_38_50_957Z-debug.log
I tried to install globally a package using yarn (coming by default with the Docker image):
/ # yarn global add elm
yarn global v1.13.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
warning Your current version of Yarn is out of date. The latest version is "1.15.2", while you're on "1.13.0".
info To upgrade, run the following command:
$ curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
success Installed "[email protected]" with binaries:
- elm
Done in 8.90s.
/ # elm --version
0.19.0
I think the problem is not with the Docker image itself but with the package manager.
My company does scans for vulnerabilities in our Docker images. We kept failing because of fstream
, which was part of npm. Since npm got updated today, I tried to update it globally on the image and kept running into errors. I had to change ownership on several folders to get it to work. Here's what I did to get it to work.
RUN chown -R node:node /home/node/app /usr/local/lib/node_modules /usr/local/bin /usr/local/share/man
USER node
RUN npm i -g npm@latest
Hi there!
I am facing the same kind of issue. While I was trying to install Protractor using npm install -g protractor
, I got the EACCES
error as of this type-
npm ERR! path /usr/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/lib/node_modules'] {
npm ERR! stack: "Error: EACCES: permission denied, access '/usr/lib/node_modules'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! /home/nishant/.npm/_logs/2019-08-20T13_50_35_126Z-debug.log
This was resolved by changing the permission in /usr/lib/node_modules
.
But again while running npm install -g protractor
, I got the same issue but with slight change as dest
is also added there as of this type-
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall symlink
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/protractor/bin/protractor' -> '/usr/bin/protractor'
npm ERR! [OperationalError: EACCES: permission denied, symlink '../lib/node_modules/protractor/bin/protractor' -> '/usr/bin/protractor'] {
npm ERR! cause: [Error: EACCES: permission denied, symlink '../lib/node_modules/protractor/bin/protractor' -> '/usr/bin/protractor'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/protractor/bin/protractor',
npm ERR! dest: '/usr/bin/protractor'
npm ERR! },
npm ERR! stack: "Error: EACCES: permission denied, symlink '../lib/node_modules/protractor/bin/protractor' -> '/usr/bin/protractor'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/protractor/bin/protractor',
npm ERR! dest: '/usr/bin/protractor'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! /home/nishant/.npm/_logs/2019-08-20T13_58_18_342Z-debug.log
But changing the permission of path
as well as dest
is raising another error as no such file pr directory exist
. Can anyone help me in resolving this problem?
@nipan09 Try adding /usr/bin
to the list of folders which gets their permissions updated.
`(base) programmer@programmer-Lenovo-ideapad-320-15ISK:~$ npm install -g expo-cli@3 npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial). npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies. npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2. npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3. npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial). npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial). npm WARN deprecated [email protected]: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial). npm WARN deprecated [email protected]: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues. npm WARN deprecated [email protected]: This module has moved and is now available at @hapi/topo. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues. npm WARN checkPermissions Missing write access to /usr/lib/node_modules npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules/expo-cli/node_modules/@expo/traveling-fastlane-darwin): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules/expo-cli/node_modules/@expo/ngrok-bin/node_modules/@expo/ngrok-bin-linux-arm64): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules/expo-cli/node_modules/@expo/ngrok-bin/node_modules/@expo/ngrok-bin-freebsd-x64): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"freebsd","arch":"x64"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules/expo-cli/node_modules/@expo/ngrok-bin/node_modules/@expo/ngrok-bin-darwin-x64): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules/expo-cli/node_modules/@expo/ngrok-bin/node_modules/@expo/ngrok-bin-win32-ia32): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"win32","arch":"ia32"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules/expo-cli/node_modules/@expo/ngrok-bin/node_modules/@expo/ngrok-bin-darwin-ia32): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"darwin","arch":"ia32"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules/expo-cli/node_modules/@expo/ngrok-bin/node_modules/@expo/ngrok-bin-sunos-x64): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"sunos","arch":"x64"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules/expo-cli/node_modules/@expo/ngrok-bin/node_modules/@expo/ngrok-bin-linux-arm): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"linux","arch":"arm"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules/expo-cli/node_modules/@expo/ngrok-bin/node_modules/@expo/ngrok-bin-freebsd-ia32): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"freebsd","arch":"ia32"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules/expo-cli/node_modules/@expo/ngrok-bin/node_modules/@expo/ngrok-bin-linux-ia32): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"linux","arch":"ia32"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @expo/[email protected] (node_modules/expo-cli/node_modules/@expo/ngrok-bin/node_modules/@expo/ngrok-bin-win32-x64): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @expo/[email protected]: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/expo-cli/node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":"<8.10.0"} (current: {"node":"10.20.1","npm":"6.14.4"}) npm WARN notsup Not compatible with your version of node/npm: [email protected] npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/expo-cli/node_modules/watchpack/node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code EACCES npm ERR! syscall access npm ERR! path /usr/lib/node_modules npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules' npm ERR! { [Error: EACCES: permission denied, access '/usr/lib/node_modules'] npm ERR! stack: npm ERR! 'Error: EACCES: permission denied, access '/usr/lib/node_modules'', npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/lib/node_modules' } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in: npm ERR! /home/programmer/.npm/_logs/2020-06-02T10_08_45_176Z-debug.log `
I am getting this error when i try to use command npm install -g expo-cli@3
in ubuntu terminal
I was facing this issue while building the Angular 6 image with Docker (v18.09.0).
The Proxy variables of node and Docker environment were causing the problem. The solution is to reset
httpProxy
variable value as told here: Docker doc. Also, set project specific.npmrc
like: gist and fix thenpm
permission issue: gistFinally, my
Dockerfile
looks like:FROM node:10.14.2-alpine ### #Issue: 'Cannot read property 'startsWith' of null in npm install' error #Reason: Proxy variables of node and Docker environment were causing the problem. #Solution: Modify httpProxy variable value as told here: https://docs.docker.com/network/proxy/#configure-the-docker-client # Also, set project specific .npmrc like : https://gist.github.com/nikhilbchilwant/7243ea4c6f35f28fb44376dac675d285 #RUN apk add tree WORKDIR /home/node/aas-ui #Fix for npm permission issue: https://github.com/angular/angular/blob/f8096d499324cf0961f092944bbaedd05364eea1/tools/ngcontainer/Dockerfile#L51 RUN mkdir /home/node/.npm-global \ && npm config set prefix '/home/node/.npm-global' \ && echo "export PATH=/home/node/.npm-global/bin:$PATH" >> /home/node/.profile RUN source /home/node/.profile RUN chown -R node $(npm config get prefix) RUN chown -R node /home/node/aas-ui USER node COPY src ./src/ COPY e2e ./e2e/ COPY .angular-cli.json ./angular-cli.json COPY protractor.conf.js ./protractor.conf.js COPY karma.conf.js ./karma.conf.js COPY tslint.json ./tslint.json COPY package.json . COPY angular.json . COPY .npmrc . RUN npm install --verbose RUN npm build --verbose
I hope this helps someone.
This Solution worked for me. Thanks @nikhilbchilwant