Unable to successfully create jhipster project using Docker image and install instructions - jhipster

I am attempting to follow the official jhipster install instructions from http://jhipster.github.io/installation.html I am attempting to do the Docker install. I am using Linux Mint 17.1 and have installed docker (Docker version 1.0.1, build 990021a)
I have successfully pulled the docker container, run the container using the command provided, and ssh'd into the container.
However, when I attempt to run "yo jhipster" I run into issues. It prompts me with the standard generator questions then successfully creates all the files necessary for the project itself. Near the end of the generator, after a few of the npm installs, I end up getting an error message followed by an exception.
I'm unclear where this exception is coming from or what to do to resolve it. The official documentation doesn't mention anything about this issue, nor have I been able to locate any other reports of this exact issue.
I believe whatever is causing this exception also seems to cause issues when I try and launch the project. I use "mvn spring-boot:run" and the application appears to run, but when I try and access the webpage, I don't see any of the normal generated 'default' app I would expect. Instead, all I see is the title of the page as "jhipster" and the only text on the page itself "This is your footer"
Below is the output of the "yo jhipster" command (with some of the 'create' messages redacted for space)
jhipster#234b4f2192fd:/jhipster$ yo jhipster
_ _ ___ __ _____ ____ ___ __ _____ __ __ _
| |_| | | | |_) ( (` | | | |_ | |_) ( (` | | / /\ / /` | |_/
|_| | |_| |_| _)_) |_| |_|__ |_| \ _)_) |_| /_/--\ \_\_, |_| \
____ ___ ___
| |_ / / \ | |_)
|_| \_\_/ |_| \
_ __ _ __ ___ ____ _ __
| | / /\ \ \ / / /\ | | \ | |_ \ \ / ( (`
\_|_| /_/--\ \_\/ /_/--\ |_|_/ |_|__ \_\/ _)_)
Welcome to the JHipster Generator
This is an existing project, using the configuration from your .yo-rc.json file
to re-generate the project...
create package.json
create bower.json
create README.md
identical .bowerrc
identical .gitignore
identical .gitattributes
create Gruntfile.js
create pom.xml
..........
create src/main/webapp/assets/images/development_ribbon.png
create src/main/webapp/assets/images/hipster.png
create src/main/webapp/assets/images/hipster2x.png
create src/main/webapp/index.html
identical .editorconfig
identical .jshintrc
I'm all done. Running bower install & npm install for you to install the required dependencies. If this fails, try running the command yourself.
npm WARN engine imagemin#3.1.0: wanted: {"node":">=0.10.0","npm":">=2.1.5"} (current: {"node":"0.10.33","npm":"1.4.28"})
npm WARN optional dep failed, continuing fsevents#0.3.5
> phantomjs#1.9.15 install /jhipster/node_modules/karma-phantomjs-launcher/node_modules/phantomjs
> node install.js
Download already available at /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2
Extracting tar contents (via spawned process)
Removing /jhipster/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1425335692414/phantomjs-1.9.8-linux-x86_64 -> /jhipster/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /jhipster/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/lib/phantom/bin/phantomjs
> ws#0.5.0 install /jhipster/node_modules/grunt-browser-sync/node_modules/browser-sync/node_modules/socket.io/node_modules/engine.io/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
> ws#0.4.31 install /jhipster/node_modules/grunt-browser-sync/node_modules/browser-sync/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
> ws#0.4.32 install /jhipster/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
npm WARN optional dep failed, continuing imagemin-optipng#4.2.0
npm WARN optional dep failed, continuing imagemin-gifsicle#4.1.0
npm WARN optional dep failed, continuing imagemin-jpegtran#4.1.0
npm WARN optional dep failed, continuing imagemin-pngquant#4.0.0
npm WARN prefer global yo#1.3.3 should be installed with -g
> yo#1.3.3 postinstall /jhipster/node_modules/yo
> yodoctor
Yeoman Doctor
Running sanity checks on your system
✔ No .bowerrc file in home directory
✔ Global configuration file is valid
✔ No .yo-rc.json file in home directory
✔ NODE_PATH matches the npm root
Everything looks all right!
npm ERR! EEXIST, open '/home/jhipster/.npm/ebc17495-r-npm-minimist-1-1-0-package-tgz.lock'
File exists: /home/jhipster/.npm/ebc17495-r-npm-minimist-1-1-0-package-tgz.lock
Move it away, and try again.
npm ERR! System Linux 3.13.0-37-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /jhipster
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! path /home/jhipster/.npm/ebc17495-r-npm-minimist-1-1-0-package-tgz.lock
npm ERR! code EEXIST
npm ERR! errno 47
npm ERR! not ok code 0
events.js:72
throw er; // Unhandled 'error' event
^
Error: spawn ENOENT
at errnoException (child_process.js:1001:11)
at Process.ChildProcess._handle.onexit (child_process.js:792:34)
jhipster#234b4f2192fd:/jhipster$

This seems to be a bug with the JHipster Dockerfile. I submitted a pull request today in which the node version is updated. With an updated node version there is no problem anymore.
You have two options:
Wait for this pull request to be merged, which probably won't take more than a day or two and this will trigger an update to the JHipster Docker image on DockerHub
Download the Dockerfile from my forked repository and build the image yourself using the following command in the same directory as the Dockerfile
docker build -t yourusername/jhipster-docker .
sudo docker run -v ~/jhipster:/jhipster -p 8080:8080 -p 9000:9000 -p 35729:35729 -p 4022:22 -t yourusername/jhipster-docker
This docker run command was taken from the JHipster documentation page as you mentioned before.

Have a look at these lines from the yo jhipster command
npm ERR! EEXIST, open '/home/jhipster/.npm/ebc17495-r-npm-minimist-1-1-0- package-tgz.lock'
File exists: /home/jhipster/.npm/ebc17495-r-npm-minimist-1-1-0-package-tgz.lock
Move it away, and try again.
So delete the .lock file and try again

Try ">npm cache clean" and run ">yo jhipster".. it should work.

Related

ERR! Maximum call stack size exceeded running on Azure App Service

I have a Node.js and Vue web app with code on Bitbucket that I'd like to run on Azure App Service. The code uses npm workspaces. Many things work:
Pushing to main triggers a new Oryx build on Azure.
The build completes successfully.
The app service restarts, finds the tar.gz bundled node_modules, and attempts to install.
Then npm throws an error: "Maximum call stack size exceeded":
2022-05-26T22:30:56.622181753Z Documentation: http://aka.ms/webapp-linux
2022-05-26T22:30:56.622185053Z NodeJS quickstart: https://aka.ms/node-qs
2022-05-26T22:30:56.622188353Z NodeJS Version : v16.13.1
2022-05-26T22:30:56.622191753Z Note: Any data outside '/home' is not persisted
2022-05-26T22:30:56.622195353Z
2022-05-26T22:30:57.671975654Z Starting periodic command scheduler: cron.
2022-05-26T22:30:57.819864556Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2022-05-26T22:30:57.823023597Z Build Operation ID: |mTOdVwRHTgA=.4c8dcbcb_
2022-05-26T22:30:57.840196418Z Environment Variables for Application Insight's IPA Codeless Configuration exists..
2022-05-26T22:30:58.384540918Z Writing output script to '/opt/startup/startup.sh'
2022-05-26T22:30:58.470679226Z Running #!/bin/sh
2022-05-26T22:30:58.470711626Z
2022-05-26T22:30:58.470717626Z # Enter the source directory to make sure the script runs where the user expects
2022-05-26T22:30:58.470722627Z cd "/home/site/wwwroot"
2022-05-26T22:30:58.470734227Z
2022-05-26T22:30:58.470738827Z export NODE_PATH=/usr/local/lib/node_modules:$NODE_PATH
2022-05-26T22:30:58.470743427Z if [ -z "$PORT" ]; then
2022-05-26T22:30:58.470748127Z export PORT=8080
2022-05-26T22:30:58.470752927Z fi
2022-05-26T22:30:58.470757227Z
2022-05-26T22:30:58.470761427Z echo Found tar.gz based node_modules.
2022-05-26T22:30:58.470766327Z extractionCommand="tar -xzf node_modules.tar.gz -C /node_modules"
2022-05-26T22:30:58.470770927Z echo "Removing existing modules directory from root..."
2022-05-26T22:30:58.470775527Z rm -fr /node_modules
2022-05-26T22:30:58.470779827Z mkdir -p /node_modules
2022-05-26T22:30:58.470784227Z echo Extracting modules...
2022-05-26T22:30:58.470788627Z $extractionCommand
2022-05-26T22:30:58.470792927Z export NODE_PATH="/node_modules":$NODE_PATH
2022-05-26T22:30:58.470797528Z export PATH=/node_modules/.bin:$PATH
2022-05-26T22:30:58.470802228Z if [ -d node_modules ]; then
2022-05-26T22:30:58.470806628Z mv -f node_modules _del_node_modules || true
2022-05-26T22:30:58.470823228Z fi
2022-05-26T22:30:58.470827528Z
2022-05-26T22:30:58.470831428Z if [ -d /node_modules ]; then
2022-05-26T22:30:58.470835428Z ln -sfn /node_modules ./node_modules
2022-05-26T22:30:58.470839528Z fi
2022-05-26T22:30:58.470843428Z
2022-05-26T22:30:58.470847328Z echo "Done."
2022-05-26T22:30:58.478721429Z PATH="$PATH:/home/site/wwwroot" npm i && npm start
2022-05-26T22:30:58.490088376Z Found tar.gz based node_modules.
2022-05-26T22:30:58.490684883Z Removing existing modules directory from root...
2022-05-26T22:30:58.529059677Z Extracting modules...
2022-05-26T22:31:10.105548413Z Done.
2022-05-26T22:31:11.551727987Z npm info it worked if it ends with ok
2022-05-26T22:31:11.560135195Z npm info using npm#6.14.15
2022-05-26T22:31:11.561597313Z npm info using node#v16.13.1
2022-05-26T22:31:15.244181354Z npm info lifecycle my-app#0.0.1~preinstall: my-app#0.0.1
2022-05-26T22:31:19.567653504Z npm ERR! Maximum call stack size exceeded
2022-05-26T22:31:19.593524734Z npm timing npm Completed in 8150ms
2022-05-26T22:31:19.597115780Z
2022-05-26T22:31:19.598435196Z npm ERR! A complete log of this run can be found in:
2022-05-26T22:31:19.599027604Z npm ERR! /root/.npm/_logs/2022-05-26T22_31_19_569Z-debug.log
I'm not sure of the cause of the error, but I did notice that the app is run with npm version 6.14.15, which as far as I'm aware doesn't support npm workspaces. Is it possible to upgrade npm? I tried using WEBSITE_NPM_DEFAULT_VERSION but that didn't appear to have any effect. I noticed that the Oryx build uses npm version 8.5.0.

"No git binary found" and "npm WARN tar ENOENT: no such file or directory" in docker container

This docker setup was working last week. Since then the only real changes have been some new dependencies and some minor code updates. It's what I use to deploy our app with CircleCI and nothing about this configuration has changed since last time I used it.
Docker file
FROM node:10-alpine as base
EXPOSE 3001
WORKDIR /usr/src/app
COPY server/package.json server/package-lock.json ./
RUN npm install
COPY ./server/ ./
RUN npm run build
CMD ["npm", "run", "server:prod"]
I get a bunch of errors like this:
npm WARN tar ENOENT: no such file or directory, open '/usr/src/app/node_modules/.staging/request-2b86f7e4/index.js'
And this error as well:
npm ERR! code ENOGIT
npm ERR! Error while executing:
npm ERR! undefined ls-remote -h -t ssh://git#github.com/timsuchanek/codemirror-graphql.git
npm ERR!
npm ERR! undefined
npm ERR! No git binary found in $PATH
If I remove the package-lock.json file I stop getting this error npm WARN tar ENOENT: no such file or directory. But I still get No git binary found in $PATH.
NOTE: that if I run npm install outside the Docker container it works fine.
This is driving me mad is it's suddenly stopped working and we can't deploy any updates to our app. Any help would be appreciated.
EDIT: ---
I added the following to the docker file (based on the answer below) and it fixed the issue.
RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh
Docker description of node:alpine image says:
To minimize image size, it's uncommon for additional related tools (such as git or bash) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see the alpine image description for examples of how to install packages if you are unfamiliar).
See the description
You will need to add a ssh key to the container with right permission.
check this for reference https://medium.com/paperchain/fetching-private-github-repos-from-a-docker-container-273f25ec5a74

Why does `package-lock.json` causes a failure in a docker container build when `npm install`?

There are a lot of people online asking this same question in different ways but there is no clear answer. Can anybody understand enough to explain why a docker build fails when package-lock.json file exists in the application, but runs successfully when it is not? Seemingly it is related to npm but it is not clear.
Everybody says delete the package-lock.json, but it is there for a reason.
Note: npm install works fine on my local machine, just fails in docker container.
If I have this Dockerfile:
# First Stage: Builder
FROM node:13.12.0-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
And run this:
docker build -t container-tag ./
I get this:
npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/eventsource-c2615740/example/index.html'
npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/eventsource-c2615740/example/sse-client.js'
npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/react-router-a14663ae/README.md'
But this Dockerfile will run successfully:
# First Stage: Builder
FROM node:13.12.0-alpine AS build
WORKDIR /app
COPY package.json ./ #<-------- note that there is no star here
RUN npm install
COPY . .
RUN npm run build
From your question:
Note: npm install works fine on my local machine, just fails in docker container
If you are using npm install, you are not sure to have the same version of dependencies.
For having a reproducible environment, without unexpected issues because of different version of dependencies, you'd rather use npm ci (clean-install):
This command is similar to npm-install, except it’s meant to be used
in automated environments such as test platforms, continuous
integration, and deployment – or any situation where you want to make
sure you’re doing a clean install of your dependencies. It can be
significantly faster than a regular npm install by skipping certain
user-oriented features. It is also more strict than a regular install,
which can help catch errors or inconsistencies caused by the
incrementally-installed local environments of most npm users.
In short, the main differences between using npm install and npm ci
are:
The project must have an existing package-lock.json or
npm-shrinkwrap.json.
If dependencies in the package lock do not match those in package.json, npm ci will exit with an error, instead of updating the package lock.
npm ci can only install entire projects at a time: individual dependencies cannot be added with this command.
If a node_modules is already present, it will be automatically removed before npm ci begins its install.
It will never write to package.json or any of the package-locks: installs are essentially frozen.
A Fabian Gander's article gives further clarification about the npm install and npm ci tools and provides advice on when to use each one. The below table is from that source:
cases | npm install | npm ci
--------------------------------------|-------------|-------------
needs package.json | no | yes
needs package-lock.json | no | yes
installs from package.json | yes | no
installs from package-lock.json | no | yes
compares both | no | yes
updates loose package versions | yes | no
updates loose dependencies | yes | no
writes to package.json | yes | no
writes to package-lock.json | yes | no
deletes node_modules before install | no | yes
used for installing separate package | yes | no
should be used on build systems / CI | no | yes
can be used for development | yes | yes
reproducible installs | no | yes
This is why package-lock.json is there, to be available for tools like npm ci.
After having a reproducible environment, if this doesn't fix your issue, you need to keep investigating, but IMO it should be the first step.
Some reasons your local build succeeded but the Docker build failed could have been (in order of likelihood)
you've overwritten the Alpine Linux version of your node_modules folder with the node_modules folder from your host, because you didn't .dockerignore node_modules and issued a COPY / ADD command when node_modules exists in . on the host
However, I can't explain why omitting the package-lock.json from the COPY would then make the build work. So the problem could also have involved:
when you generated your package-lock.json, you npm install-ed locally under a different version of node than specified in your Dockerfile
when you generated your package-lock.json, you built locally under a different operating system than Alpine Linux
when you generated your package-lock.json, you npm install-ed locally under a different version of npm from the Docker container, it may have treated the lockfile relationship differently
All of these actions potentially will cause a package-lock.json to be generated that may cause an npm install (and more likely cause a npm ci) in the container to fail. I'm not sure why these would cause the specific errors you posted though.
If these reasons could be the issue, the proper solution to the problem is surely to do all your npm manipulation (including your generation and manipulation of package.json and package-lock.json) inside the same specification of docker container that you intend to ship the code in, and work out a way to commit the results to source control from there. This can be complicated by issues like there being several needs to build your node_modules in the same environment you push source-code changes from (for instance a build step whose results need pushing into the container, or a git hook that needs installing). I've not yet seen a perfect solution to this issue

Docker Volume: ENOENT: no such file or directory, open '/app/package.json'

I'm using Docker using Docker Toolbox because of I have Windows Home. I made a React application using:
npx create-react-app frontend
Thus I made a "Dokerfile.dev" file in which I say doicker to use base image node alpine version, setting working directory "/app", to copy "package.json" that needs to install node "run npm install", and then I say to copy the other files. I put also the command to be enable when I start that container:
FROM node:alpine
WORKDIR '/app'
COPY package.json .
RUN npm install
COPY . .
CMD ["npm","run","start"]
And seems work, because of if I build:
docker build -f Dockerfile.dev .
and run it mapping container port to local port (3000):
docker run -it -p 3000:3000 [containerID]
it works on http://192.168.99.100:3000, react page working.
After that, I wanna try to run using volume. Actually I delete node_modules dependency from "app" folder, because of npm install it double. This I put it like a placeholder. Instead, I map the Present Working Directory (pwd) with "/app":
docker ruyn -it -p 3000:3000 -v /app/node_modules -v /c/Program\ Files/Docker\ Toolbox/frontend:/app -e CHOKIDAR_USEPOLLING=true a631964d87b2
(my pwd contains whitespaces, thus I have to use "\ " isntead of "". "a631964d87b2" is my container id)
The result is:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /app/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/app/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-05-23T20_10_26_143Z-debug.log
Why it works without Volume, instead using volume it says that it doesn't found /app/package.json? That's impossible because of in Dockerfile.dev I say:
COPY package.json .
thus to copy package.json to the current working directory which is "/app".
--- UPDATE
Actually it works if I move project inside c:/Users/username
and I text this:
docker run -it -p 3000:3000 -v /app/node_modules -v $(pwd):/app -e CHOKIDAR_USEPOLLING=true a631964d87b2
That's because $(pwd) puts my Present Working Directory, and in that case it doesn't have whitespaces inside it. How I can put my plan working directory with namespaces?
--- UPDATE 2
problem are not whitespaces: I tried to modify c:/Users/username/frontend in c:/Users/username/abc\ frontend
and it still works. It seems that project must be in users and not in program files
?
The problem was that project was outside Window Users folder, in fact it was in Program Files. Trying to move it in Users/myUser, it works also using a path with whitespaces

sh: 1: node: Permission denied

Tried to run this command on ubuntu 18.04
npm install -g pngquant-bin
but I got this error,
[..................] | fetchMetadata: sill resolveWithNewModule npm-conf#1.1.3 checking installable status
npm WARN deprecated gulp-util#3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
/root/.nvm/versions/node/v10.8.0/bin/pngquant -> /root/.nvm/versions/node/v10.8.0/lib/node_modules/pngquant-bin/cli.js
> pngquant-bin#5.0.0 postinstall /root/.nvm/versions/node/v10.8.0/lib/node_modules/pngquant-bin
> node lib/install.js
sh: 1: node: Permission denied
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! pngquant-bin#5.0.0 postinstall: `node lib/install.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the pngquant-bin#5.0.0 postinstall 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-08-12T18_08_02_197Z-debug.log
Do you do you know how to deal with this?
I tried every solution found in this articles yet not succeeded.
Got the same error sh: 1: node: Permission denied
So this worked for me
npm config set user 0
npm config set unsafe-perm true
These issues happen because of broken packages. Go to the main folder. If using Linux use command
sudo rm -rf node_modules.
After that run this command if you are using yarn
yarn install
If you are using npm run this command
npm install
Delete the node_modules and install it again
sudo rm -rf node_modules
npm install
in fact, npm can't use root account to install anything. if you use root account, npm will create a non-permission account to install. in this case, if the package need to execute writeFile or other operation which need permission, the error node: Permission denied will be raised.
so, you can choose optional arbitrary under:
npm install xxx --unsafe-perm
npm config set unsafe-perm true
create high-permission account dedicate to execute npm install
In my case it was a silly typo, I was forgotten to add node into the front of the start command in package.json. So I've changed:
"scripts": {
"start": "app/server.js"
}
... to:
"scripts": {
"start": "node app/server.js"
}
The /root/.npm/... log path in your original message shows you're already running as root, and (despite what others advise) I'd say this is most likely causing your problem.
My (limited) experience running Node as root is that most npm install runs get quite a long way, but then fail with some variation on the error you showed. The only reliable solution I've found is to not run Node or npm as root at all on Ubuntu. Just use a normal user account to download and unpack the Node installation.
At least one problem with running as root for me turned out to be because some dependency-of-a-dependency npm install script was calling setuid to switch to a less-privileged user. For some reason, it chose UID 500—which doesn't exist on Ubuntu—and consequently lost all its privileges. The 'Permission denied' errors were therefore because I was running as root; setuid doesn't work for a normal user.
I believe this is related to Error: setuid user id does not exist npm ERR! when npm install forever -g.
Solved my problem chmod -R a+x node_modules
As far as my understanding goes the os is blocking your ability to execute commands described in node_modules so by my understanding what this command does is say everything in node_modules is okay to execute.
By the time I found the solution it was 4 AM, so I didn't really bother to figure out what I actually did. If someone knows what -R a+x node_modules does exactly feel free to drop it in the commands and I will make an edit.
I make the chown to project user owner (in USERID) dir and resolv the "permission denied" problem:
sudo chown -R USERID.USERID *
Additionally (and this might be useful for docker) you can override this configuration setting globally via the environment variable npm_config_user -- for example:
ENV npm_config_user=root
I ran into the same error an nothing really helped. I found a medium article explaining how to set up an angular build management. For some reason adding
- npm link #angular/cli#13.2.5
to my build script made it. I basically added all of the recommendations above. So my build script now looks like this
- ...
- npm config set user 0
- npm config set unsafe-perm true
- npm i --force
- npm link #angular/cli#13.2.5
- ...
I hope it helps! I would be happy if someone could explain why it actually worked.
This is an old question but maybe someone still need some help.
This errors often is displayed because you have defined in the package.json just the path. For example:
{
// more definitions
"scripts": {
// other scripts
"getPax8Products": "<filepath>",
// more scripts
},
// more definitions
}
In this case, you need to:
Add the following lines in the very beggining of the script
#!/usr/bin/env node
'use strict';
Give the file execution permission
# in UNIX based
chmod +x <filepath>
You also can modify the package.json and add the node command. However, you need to be aware that NPM will run in the script's directory:
{
// more definitions
"scripts": {
// other scripts
"getPax8Products": "node <filepath>",
// more scripts
},
// more definitions
}
For Deploying with Docker:
make sure /node_modules is deleted or added to dockerignorefile
make sure /dist is deleted or added to dockerignorefile
the problem was solved for me by deleting both files
and build them in the container
For me, I had not installed my dependencies. node_modules did not exist, but I had jest installed globally apparently. Running npm ci and then running npm test solved my issue.
npm install lite-server --save-dev
packages.json:
"scripts": {
"dev": "lite-server",
},
"devDependencies": {
"lite-server": "^2.6.1"
}
npm run dev
I stuck with same issue when tried to install packages into AWS Sagemaker instance
The issue coming because NPM by default install new global packages into ~/.npm-global
When you run npm install -g by root, npm is try to install package into /root/.npm-global/..., and stuck with access denied.
Simply workaround to re-config global folder for npm.
(https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally)
Here is example of install obj2gltf
mkdir /npm-global
npm config set prefix '/npm-global'
export PATH=/npm-global/bin:$PATH
npm install -g obj2gltf
I had that error too and tried the above solutions without any change. My error was caused because I had Windows (11) with a WSL and NVM installed on both operating systems. I had to uninstall NVM on my Windows to resolve the conflicts.
I think if you develop in your WSL and have a resource installed on both operating systems, a dependency might point to the wrong operating system with the resource (in my case to the NVM on Windows). The WSL user didn't have sufficient permissions to perform any execution on the Windows machine, which lead to the error.
you need root user permission, just add sudo keyword before the command and write your password
sudo npm install -g pngquant-bin
Try to install node at project folder
npm install node

Resources