Updating npm in Docker image - node.js

I am building a Node.js Docker image: docker build . -t imagename, however I keep getting warning regarding npm version
npm WARN deprecated This version of npm lacks support for important features,
npm WARN deprecated such as scoped packages, offered by the primary npm
npm WARN deprecated registry. Consider upgrading to at least npm#2, if not the
npm WARN deprecated latest stable version. To upgrade to npm#2, run:
npm WARN deprecated
npm WARN deprecated npm -g install npm#latest-2
npm WARN deprecated
npm WARN deprecated To upgrade to the latest stable version, run:
npm WARN deprecated
npm WARN deprecated npm -g install npm#latest
npm WARN deprecated
npm WARN deprecated (Depending on how Node.js was installed on your system, you
npm WARN deprecated may need to prefix the preceding commands with `sudo`, or if
npm WARN deprecated on Windows, run them from an Administrator prompt.)
npm WARN deprecated
npm WARN deprecated If you're running the version of npm bundled with
npm WARN deprecated Node.js 0.10 LTS, be aware that the next version of 0.10 LTS
npm WARN deprecated will be bundled with a version of npm#2, which has some small
npm WARN deprecated backwards-incompatible changes made to `npm run-script` and
npm WARN deprecated semver behavior.
However I have update Node.js version, and it still wouldn't work:
node -v
v8.9.3
npm -v
5.6.0
I have ran npm -g install npm#latest but still won't work.
Dockerfile
FROM alpine:3.1
# Update
RUN apk add --update nodejs
# Install app dependencies
COPY package.json /src/package.json
RUN cd /src; npm -g install npm#latest
# Bundle app source
COPY . /src
CMD ["node", "--harmony","/src/app.js"]
What could possibly be the cause? I am able to run the app using node just fine.
I'm running Ubuntu 16.04.3 LTS

In Dockerfile, I used latest alpine version FROM alpine:3.7 instead and it works.

You must run docker image pull node to download the latest node (npm included) image locally before building your image.
Hope that helps!

Related

Mac: Expo being updated but not working and resolving out-of-date packages

I have the expo-cli working fine on Windows with a project initialized and running which I'd like to be able to do on this machine. However, on Mac, it keeps saying that the package is getting updated but when I try running expo init or the expo command globally it doesn't work:
/Users/daggerpov/.npm/bin/expo -> /Users/daggerpov/.npm/lib/node_modules/expo-cli/bin/expo.js
/Users/daggerpov/.npm/bin/expo-cli -> /Users/daggerpov/.npm/lib/node_modules/expo-cli/bin/expo.js
+ expo-cli#4.11.0
updated 2 packages in 94.007s
daggerpov#Daniels-MBP ~ % expo
zsh: command not found: expo
Also, I get a bunch of deprecation warnings but I've heard it's expected by installing this through npm, nevertheless here's the full output:
daggerpov#Daniels-MBP ~ % npm install -g expo-cli
npm WARN deprecated graphql-tools#3.0.0: This package has been deprecated and now it only exports makeExecutableSchema.\nAnd it will no longer receive updates.\nWe recommend you to migrate to scoped packages such as #graphql-tools/schema, #graphql-tools/utils and etc.\nCheck out https://www.graphql-tools.com to learn what package you should use instead
npm WARN deprecated uuid#3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url#0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated querystring#0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents#1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated uuid#3.0.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
/Users/daggerpov/.npm/bin/expo -> /Users/daggerpov/.npm/lib/node_modules/expo-cli/bin/expo.js
/Users/daggerpov/.npm/bin/expo-cli -> /Users/daggerpov/.npm/lib/node_modules/expo-cli/bin/expo.js
+ expo-cli#4.11.0
updated 2 packages in 94.007s
What I've done to try resolving the issue of not being able to use the expo command has been:
installing Watchman through homebrew (it had no errors and came out fine)
running cd ~/node_modules && npm i expo-cli && sudo npm i -g expo && sudo npm i --global expo-cli
I followed this YouTube tutorial which said to run npm install expo-cli global which resulted in this:
daggerpov#Daniels-MBP ~ % npm install expo-cli global
(just some of the same deprecation warnings)
npm WARN checkPermissions Missing write access to /Users/daggerpov/node_modules/expo-cli
npm WARN daggerpov#1.0.0 No description
npm WARN daggerpov#1.0.0 No repository field.
npm ERR! code ELOOP
npm ERR! syscall access
npm ERR! path /Users/daggerpov/node_modules/expo-cli
npm ERR! errno -62
npm ERR! ELOOP: too many symbolic links encountered, access '/Users/daggerpov/node_modules/expo-cli'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/daggerpov/.npm/_logs/2021-09-10T06_57_31_944Z-debug.log
Perhaps since my node version is a little more recent than the LTS it could pose a problem?
daggerpov#Daniels-MBP ~ % node --version
v14.8.0
daggerpov#Daniels-MBP ~ % npm --version
6.14.8
UPDATE: I've changed my node version to the LTS and have made sure that usr/local/bin is in $PATH but this did not fix the issue.
daggerpov#Daniels-MBP ~ % echo $PATH
/Users/daggerpov/.pyenv/shims:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
daggerpov#Daniels-MBP ~ % node --version
v14.17.6
I've installed nvm by following what was outlined in this issue: then I ran nvm install node and it gave me v16.9.0. Then, I ran npm install --global expo-cli as I did before and the expo command now runs fine.
Important note:
The expo command would only work right after using the nvm install node command so when I went to VSC I had to use that before every session. I will try to find a solution to this issue and edit this answer accordingly. So, this is how you configure your node version using nvm and have it stay. Personally, I did nvm use 16.9.0 then when I checked my node version it saved.

How to fix 'npm does not support Node.js v11.14.0 error' on Windows?

I am configuring my react-native environment. I am attempting to run the react-native command line as described in Facebook's Github documentation here
I have installed the latest version of node.js when I type C:\WINDOWS\system32>node -v v11.14. is returned.
The npm downloaded was included with the latest version of node.js. However it is only 5.5.1. When I input C:\WINDOWS\system32>npm -v the result is 5.5.1
I've tried to uninstall and reinstall
I've tried to download the LTS version of node.js
I've tried to upgrade both node.js and npm
This is for Windows 10
This is running from the administrative command prompt and administrative power shell
This is the code
C:\WINDOWS\system32>npm install -g react-native-cli
npm WARN npm npm does not support Node.js v10.15.3
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! Cannot read property 'startsWith' of null
npm ERR! A complete log of this run can be found in:
When I attempt to clean the cache with npm cache clean -f this is the result
C:\WINDOWS\system32>npm cache clean -f
npm WARN npm npm does not support Node.js v10.15.3
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
npm WARN using --force I sure hope you know what you are doing.
Edits
The following code is a result of some of the proposed solutions
C:\WINDOWS\system32>npm install -g npm
npm WARN npm npm does not support Node.js v11.14.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! Cannot read property 'startsWith' of null
npm ERR! A complete log of this run can be found in:
C:\WINDOWS\system32>npm install -g npm-windows-upgrade
npm WARN npm npm does not support Node.js v11.14.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! Cannot read property 'startsWith' of null
npm ERR! A complete log of this run can be found in:
C:\WINDOWS\system32>npm install -g npm-windows-upgrade
npm WARN npm npm does not support Node.js v11.14.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! Cannot read property 'startsWith' of null
npm ERR! A complete log of this run can be found in:
I expect to open the npm command line interface. I am receiving errors when I attempt to call the interface.
After installing current NodeJS LTS, I still get
npm does not support Node.js {version}.
I deleted all files in C:\Users\{user}\AppData\Roaming\npm\ and it works.
npm install -g npm-windows-upgrade
npm-windows-upgrade
I deleted node and npm from C:\Users{name}\AppData\Roaming. Then i reinstalled an older version node.js v10.15.3 and npm 6.4.1.
This brings up a different error so I'll be closing this issue...
C:\>npm install -g expo-cli
npm ERR! Cannot read property 'startsWith' of null
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dnort\AppData\Roaming\npm-cache\_logs\2019-04-15T06_32_09_154Z-
debug.log
Simple solution is upgrade your npm version or second option is downgrade your node version.
Download older node version from here
https://nodejs.org/en/download/releases/
How do I update npm?
npm install -g npm
Please note that this command will remove your current version of npm.
Make sure to use sudo npm install -g npm if on a Mac.
You can also update all outdated local packages by doing npm
update without any arguments, or global packages by doing npm update
-g.
Occasionally, the version of npm will progress such that the current
version cannot be properly installed with the version that you have
installed already. (Consider, if there is ever a bug in the update
command.) In those cases, you can do this
You are using an old version of npm. Please upgrade it to the latest.
I faced the same issue using npm, so I was thinking about the alternative of npm. And, you might give the yarn a try.
Firstly, going to https://nodejs.org/en/ to download the nodejs with the LTS version.
Secondly, going to https://yarnpkg.com to download the msi file with the stable version.
Note that the current version of nodejs and yarn are 10.16.0 LTS and 1.17.3 respectively.
After installation, you can install your project packages by using yarn install instead of npm install.
Had the same issue with latest version.
Remove all the NodeJS installation.
For now npm supports node js versions 6, 8, 9, 10, 11.
Go to this version (or older) download the msi file and then do npm install.

How to suppress deprecation warning from npm/nvm in zsh?

I am using nvm for managing node versions. I have installed it as a plugin to zsh via zsh-nvm. I have installed two versions of node - v6.1.0 and v.0.10.42. Since I am working on a project, which uses the latter one, I have set it at the default one. Now, every time I open a terminal window, I get these warnings:
npm WARN deprecated This version of npm lacks support for important features,
npm WARN deprecated such as scoped packages, offered by the primary npm
npm WARN deprecated registry. Consider upgrading to at least npm#2, if not the
npm WARN deprecated latest stable version. To upgrade to npm#2, run:
npm WARN deprecated
npm WARN deprecated npm -g install npm#latest-2
npm WARN deprecated
npm WARN deprecated To upgrade to the latest stable version, run:
npm WARN deprecated
npm WARN deprecated npm -g install npm#latest
npm WARN deprecated
npm WARN deprecated (Depending on how Node.js was installed on your system, you
npm WARN deprecated may need to prefix the preceding commands with `sudo`, or if
npm WARN deprecated on Windows, run them from an Administrator prompt.)
npm WARN deprecated
npm WARN deprecated If you're running the version of npm bundled with
npm WARN deprecated Node.js 0.10 LTS, be aware that the next version of 0.10 LTS
npm WARN deprecated will be bundled with a version of npm#2, which has some small
npm WARN deprecated backwards-incompatible changes made to `npm run-script` and
npm WARN deprecated semver behavior.
I tried adding a ~/.npmrc file, in which I put loglevel="error", but I still get these warnings. I guess I need to put some setting in my .zshrc file. Could you point me to which one?
As far as I'm aware, the only way to suppress these warnings (from npm) is to use a version of npm that doesn't emit them.
NODE_NO_WARNINGS=1 npm install ...

Error while installing generator-mean-seed

I am trying to follow the instructions given on https://www.npmjs.com/package/generator-mean-seed
When i try to run "sudo npm install -g generator-mean-seed" i get this error
npm install -g generator-mean-seed
npm WARN deprecated lodash#1.3.1: lodash#<2.0.0 is no longer maintained. Upgrade to lodash#^3.0.0
npm WARN deprecated CSSselect#0.7.0: the module is now available as 'css-select'
npm WARN deprecated CSSwhat#0.4.7: the module is now available as 'css-what'
npm WARN deprecated lodash#1.2.1: lodash#<2.0.0 is no longer maintained. Upgrade to lodash#^3.0.0
/usr/local/lib
├── generator-mean-seed#1.1.26
└── UNMET PEER DEPENDENCY yo#>=1.0.0
npm WARN generator-mean-seed#1.1.26 requires a peer of yo#>=1.0.0 but none was installed.
It says that i need yo installed with version > 1.0.0 but i already have that installed
yo --version
1.6.0
Any idea on what i am doing wrong or any clue to fix this?
I had the same problem ... the reason seems that the installation of peer dependencies changed in later version of npm. As a workaround, include yo when installing generator-mean-seed (it doesn't matter it's already installed):
$ sudo npm install -g yo generator-mean-seed
this way, generator-mean-seed will install correctly:
$ sudo npm install -g yo generator-mean-seed
npm WARN deprecated lodash#1.3.1: lodash#<3.0.0 is no longer maintained. Upgrade to lodash#^4.0.0.
npm WARN deprecated CSSselect#0.7.0: the module is now available as 'css-select'
npm WARN deprecated CSSwhat#0.4.7: the module is now available as 'css-what'
npm WARN deprecated lodash#1.2.1: lodash#<3.0.0 is no longer maintained. Upgrade to lodash#^4.0.0.
npm WARN deprecated graceful-fs#3.0.8: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs#^4.0.0 as soon as possible.
npm WARN deprecated npmconf#2.1.2: this package has been reintegrated into npm and is now out of date with respect to npm
/usr/local/bin/yo -> /usr/local/lib/node_modules/yo/lib/cli.js
> yo#1.7.0 postinstall /usr/local/lib/node_modules/yo
> yodoctor

Problems install Ghost 0.5.0 - npm WARN unmet dependency

I get the follow error when trying to install Ghost on ubuntu,
Node version
node -v
v0.10.22
NPM version
npm -v
1.4.21
Install output
sudo npm install --production
npm WARN package.json express#4.8.3 No README data
npm WARN package.json moment#2.4.0 No README data
npm WARN package.json mysql#2.1.1 No README data
npm WARN unmet dependency /usr/share/nginx/www/lm-ghost-0.5/node_modules/bookshelf requires semver#'~2.3.0' but will load
npm WARN unmet dependency /usr/share/nginx/www/lm-ghost-0.5/node_modules/semver,
npm WARN unmet dependency which is version 2.2.1
npm WARN unmet dependency /usr/share/nginx/www/lm-ghost-0.5/node_modules/knex requires semver#'^2.3.0' but will load
npm WARN unmet dependency /usr/share/nginx/www/lm-ghost-0.5/node_modules/semver,
npm WARN unmet dependency which is version 2.2.1
Recommendations appreciated!
I've just done a download of the latest official release from here:
https://github.com/TryGhost/Ghost/releases
Then I've run npm install --production and the only warning I get is this:
npm WARN engine html-to-text#0.1.0: wanted: {"node":"~0.8.0"} (current: {"node":"0.10.30","npm":"1.4.23"})
Are you sure you've downloaded the latest release version and not the github repository instead or another version?
Try to install ghost from that link in a clean directory, without sudo and see if it's still giving you warning.
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
//This will install the latest stable version or you can go to https://nodejs.org for the latest 'recommended for most users' version and use:
sudo n 4.6.0

Resources