I have a CI script to compile a nativescript mobile application that runs in a docker container.
When I try to run it, I get the following error:
npm ERR! code ENOENT
npm ERR! syscall rename
npm ERR! path /app/node_modules/.staging/proxy-lib-1731e398
npm ERR! dest /app/node_modules/nativescript/node_modules/proxy-lib
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, rename '/app/node_modules/.staging/proxy-lib-1731e398' -> '/app/node_modules/nativescript/node_modules/proxy-lib'
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! /.npm/_logs/2020-02-20T10_15_12_334Z-debug.log
Could not update the project! Reason is: Command npm failed with exit code 254
From what I have been able to establish, this seems to be a NPM related issue, regarding permissions.
The strange thing is that the behaviour is only showing up when used through docker.
Compiling the application on my host works, but when I do so in a docker container in the same host, I get this error.
I have messed a lot with the permissions of the npm related folders, as I have witnessed a similar issue in the past, but now I don't seem to be able to get this to work.
Regarding docker and permissions, this is what I have set at the moment:
# fix for docker npm permissions
RUN mkdir -p /.npm
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /.npm
# fix for docker npm permissions
RUN mkdir -p /.config
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /.config
# fix for docker npm permissions
RUN mkdir -p /root/.npm
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /root/.npm
# fix for docker npm permissions
RUN mkdir -p /root/.config
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /root/.config
# needed for npm install and nativescript install
RUN mkdir -p $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
RUN chown -R $DOCKER_USER:$DOCKER_GROUP $NVM_DIR/versions/node/v$NODE_VERSION/
# needed for nativescript install
RUN mkdir -p /.local
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /.local
# change owner of android sdk
RUN chown -R $DOCKER_USER:$DOCKER_GROUP $ANDROID_HOME
# change owner of android local settings folder
RUN mkdir -p /.android
RUN touch /.android/repositories.cfg
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /.android
# change owner of android local settings folder
RUN mkdir -p /.gradle
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /.gradle
# change owner of crashlytics local settings folder
RUN mkdir -p /.crashlytics
RUN chown -R $DOCKER_USER:$DOCKER_GROUP /.crashlytics
The docker user and group variables are 106 and 112 respectively.
NPM version is 6.13.4
Node version is v12.14.0
** UPDATE **
Based on the comment left by David Maze, I am leaving here some additional information:
I am running a docker container using the below command, and only mapping the volume regarding the folder in the host that contains the source. One of the first step of the builds is deleting completely the node modules folder, as well as cleaning the cache.
Docker command:
docker run -it -v my_host_folder:/app alfasoft/node-nativescript:0.17 bash
After that, and inside the docker container, I am running all the steps I had in my Jenkinsfile (su to jenkins user, change to bash and then run all of this):
rm -rf node_modules
source /usr/local/nvm/nvm.sh
nvm use default
echo "Clearing NPM Cache"
npm cache clear --force
echo "Running NPM Install"
npm install
echo "Install angular devkit"
npm install --save --unsafe-perm #angular-devkit/build-angular
echo "Installing Nativescript"
npm install -g nativescript
echo "Installing TNS"
tns install
echo "TNS doctor"
tns doctor
echo "TNS platform remove android"
tns platform remove android
echo "TNS platform add android"
tns platform add android
echo "TNS update"
tns update
echo "build android"
tns build android --hmr --env.prod --clean --env.snapshot --env.uglify
Any hint on why this might be happening?
Related
I am testing a JavaScript app that is hung up on an 'invalid ELF header'.
A wide open search finds multiple solutions.
Suggested solutions (in no particular order:)
add .dockerignore
add node_modules
install npm
rm -rf node_modules
add bcrypt("*") to package.json
npm install --global
npm
install -g node#6.17.1
use nvm to install node.js and npm
npm rebuild bcryptjs / bcrypt.js
npm rebuild bcrypt --build-from-source
rm -rf node_modules
Trying them at random has not helped. I am using a Jelastic platform to run a server.js app that was built in Eclipse on Windows 10. The app worked in localhost. So, I expected it to run in a Jelastic environment. But, I have exhausted vendor support for ERR_DLopen_FAILED.
When I run npm install, I'm getting the following error:
How can I solve this?
Update your node.js to the latest
make sure that the node version is up to date by running:
$ node -v
in your CMD and by visiting
https://nodejs.org/en/download/current/
To know what is the latest version.
run this command in your CMD:
$ npm cache clean --force
then Delete node_modules by running:
$ rmdir /S /Q node_modules
or delete it manually by going into the directory and right-click > delete / move to trash. If you are not updating your packages you can delete the package-lock.json file too.
now you can run:
$ npm install
This works for me, all the best.
I'm using git bash that was installed with the git for windows bundle, and this is what I have:
where node
C:\Program Files\nodejs\node.exe
where npm
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
But running any npm run * related script tells me that npm can't be found. Not sure what is wrong with the setup, as the paths seem right and "where" can find them. I can execute npm and node from this git bash (for example I can run node -v and npm -v) but I can't run any script.
I tried reinstalling both node and git bash but it didn't have any effect.
Any idea what could be wrong?
I am having a problem with using Docker to provide a development environment for Angular 5 on Windows 10.
Here's my ng version info:
Angular CLI: 1.6.8
Node: 6.11.0
OS: win32 x64
Angular: 5.2.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
#angular/cli: 1.6.8
#angular-devkit/build-optimizer: 0.0.42
#angular-devkit/core: 0.0.29
#angular-devkit/schematics: 0.0.52
#ngtools/json-schema: 1.1.0
#ngtools/webpack: 1.9.8
#schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0
To try and find the solution to my problem, I used the Angular CLI (latest version) to create a new project, docker-test using:
ng new docker-test
I then cd'd into docker-test and added a dockerfile as shown below:
FROM node:8
RUN mkdir -p /app
WORKDIR /app
COPY package.json /app/
RUN ["npm", "install"]
COPY . /app
EXPOSE 4200/tcp
EXPOSE 49153/tcp
CMD ["npm", "start"]
If I run 'ng serve' from Powershell, the app is served without a problem.
However, when trying to use Docker, I hit a problem.
Having removed all images and containers using:
docker rmi $(docker images -q)
docker rm $(docker ps -a -q)
I am able to successfully build the image using:
docker build -t docker-test -f dockerfile .
and can 'docker run' successfully using:
docker run --rm -it -p 4200:4200 -p 49153:49153 docker-test:latest
However, if I attempt to use volumes to allow live updates using the following command:
docker run -it --rm -p 4200:4200 -p 49153:49153 -v ${pwd}/src:/app/src docker-test
I get the following error:
ENOENT: no such file or directory, stat '/app/src/tsconfig.app.json'
Error: ENOENT: no such file or directory, stat '/app/src/tsconfig.app.json'
at Object.fs.statSync (fs.js:948:11)
at AngularCompilerPlugin._setupOptions (/app/node_modules/#ngtools/webpack/src/angular_compiler_plugin.js:78:16)
at new AngularCompilerPlugin (/app/node_modules/#ngtools/webpack/src/angular_compiler_plugin.js:43:14)
at _createAotPlugin (/app/node_modules/#angular/cli/models/webpack-configs/typescript.js:77:16)
at Object.getNonAotConfig (/app/node_modules/#angular/cli/models/webpack-configs/typescript.js:100:19)
at NgCliWebpackConfig.buildConfig (/app/node_modules/#angular/cli/models/webpack-config.js:41:37)
at Class.run (/app/node_modules/#angular/cli/tasks/serve.js:71:98)
at check_port_1.checkPort.then.port (/app/node_modules/#angular/cli/commands/serve.js:123:26)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! docker-test#0.0.0 start: `ng serve --host 0.0.0.0 --poll 500`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the docker-test#0.0.0 start 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-02-12T19_50_23_145Z-debug.log
and I can't work out what the problem is.
The file is on the host:
I get the same error if I use the following docker-compose.yaml file:
version: '3'
services:
web: # name of the service
build: ./ # specify the directory of the Dockerfile
ports:
- "4200:80"
- "49153:49153"
volumes:
- '${pwd}/src:/app/src'
Any guidance on the issue or how to debug would be very gratefully received.
so I have installed cordova using the following command to use it globally
sudo npm install -g cordova
and I get the following message
/Users/safwany/.node/bin/cordova -> /Users/safwany/.node/lib/node_modules/cordova/bin/cordova
cordova#5.1.1 /Users/safwany/.node/lib/node_modules/cordova
I keep typing cordova in the terminal but I am getting command not found. The only I can get it working is by typing the following:
/Users/safwany/.node/lib/node_modules/cordova/bin/cordova
Any idea how can I change that so I can use it globally by just typing cordova ?!
This seems to be a problem with the CHMOD rights of your folders. Try to own the folders like this:
sudo chown -R $USER /usr/local
sudo chmod -R 0775 /usr/local
after that, clear the npm cache with
sudo npm cache clear
finished? Go on by installing cordova again ->
sudo npm install -g cordova
type cordova into your terminal and everything should work like a charme.
Source: https://stackoverflow.com/a/19113963/3671726