I have a local package that I packed into an npm package using npm pack.
I then install this package to some nodejs apps that are external to this local package using npm install path/to/package.tgz. This works like a charm, but now I want to dockerize the apps and I can't manage to install the local package.
My structure looks like this:
-my_package
|-package.tgz
-app1
|-app1.js
|-Dockerfile
-app2
|-app2.js
|-Dockerfile
My Dockerfile looks like this:
FROM node:16
WORKDIR /app
# Copy and download dependencies
COPY package.json .
RUN npm install
# Copy the source files into the image
COPY . .
EXPOSE 4002
CMD ["npm", "start"]
And the error I'm getting when running docker build . -t js/app1 is:
npm WARN tarball tarball data for #my_package#file:/package.tgz (sha512-u9tY/j1VOzO1y1RpcCgYteDOEsh7TaSMYwmR2Rs7hoJopE11qa1XcnrrMKNx1/H/aHsZ3Gr0bOMx1SygYTf/rg==) seems to be corrupted. Trying again.
npm WARN tarball tarball data for #my_package#file:/package.tgz (sha512-u9tY/j1VOzO1y1RpcCgYteDOEsh7TaSMYwmR2Rs7hoJopE11qa1XcnrrMKNx1/H/aHsZ3Gr0bOMx1SygYTf/rg==) seems to be corrupted. Trying again.
npm notice
npm notice New major version of npm available! 8.19.2 -> 9.2.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.2.0>
npm notice Run `npm install -g npm#9.2.0` to update!
npm notice
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /my_package/package.tgz
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/my_package/package.tgz'
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/2022-12-09T04_54_04_868Z-debug-0.log
The command '/bin/sh -c npm ci' returned a non-zero code: 254
Some times I get null instead of the sha512 stuff, otherwise the error is the same.
Is there anything I can do to fix this?
Thanks!
The documentation says:
COPY obeys the following rules:
The path must be inside the context of the build; you cannot
COPY ../something /something, because the first step of a docker build
is to send the context directory (and subdirectories) to the docker
daemon.
The easiest fix is to paste the file(s) you need into the same folder that your Dockerfile is in.
Related
I want to start my React app, but when I run npm start, I get this error:
npm ERR! syscall open
npm ERR! path C:\Users\Muchendu\Documents\GitHub\Steve-React/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Muchendu\Documents\GitHub\Steve-React\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! C:\Users\Muchendu\AppData\Local\npm-cache\_logs\2022-05-11T09_26_37_201Z-debug-0.log
This could be because right after running
npx create-react-app <your_app_name>
you are trying to run npm start
Instead try switching into your app directory like so:
cd <your_app_name>
because that is where your package.json will most likely exist and then try running
npm start
run this command in the terminal inside your project npm init -y.
This will generate a package.json in your project.
Otherwise since you are making a react app use the npx create-react-app your-app-name this will create all the necessary files for running you application.
What is package.json?
The package.json file is the heart of any Node project. It records important metadata about a project which is required before publishing to NPM, and also defines functional attributes of a project that npm uses to install dependencies, run scripts, and identify the entry point to our package.
I have downloaded Nodejs in my Linux VM from nodejs.org, I want to install it from terminal. VM have already installed node v0.12.18 manually by someone else, I don't know how to do that. As I am installing nodejs offline, I should not depend on that whether or not npm installed.
I have tried [location]~ npm install node-v15.6.0-linux-x64.tar.gz
Getting below error
[host#machinename ~]$ sudo npm install node-v15.6.0-linux-x64.tar.gz
npm WARN excluding symbolic link bin/npm -> ../lib/node_modules/npm/bin/npm-cli. js
npm WARN excluding symbolic link bin/npx -> ../lib/node_modules/npm/bin/npx-cli. js
npm ERR! addLocal Could not install /home/usermachinename/node-v15.6.0-linux-x64.tar.g z
npm ERR! Linux 3.10.0-1062.9.1.el7.x86_64
npm ERR! argv "/usr/local/lib/nodejs/node-v0.12.18-linux-x64/bin/node" "/usr/loc al/lib/nodejs/node-v0.12.18-linux-x64/bin/npm" "install" "node-v15.6.0-linux-x64 .tar.gz"
npm ERR! node v0.12.18
npm ERR! npm v2.15.11
npm ERR! path /tmp/npm-1637-a9cb4311/unpack-5a7f411732fb/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! enoent ENOENT, open '/tmp/npm-1637-a9cb4311/unpack-5a7f411732fb/package .json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /home/usermachinename/npm-debug.log
How can I fix this?
You can't install the file using npm install, but since you already have the compressed file for node, my answer will hopefully help you achieve your goal.
First of all you will have to extract the tar.gz file you have node-v15.6.0-linux-x64.tar.gz, to do so just navigate to the folder where the file placed in then do the below command.
tar xf node-v15.6.0-linux-x64.tar.gz
Since you're using Linux the below command will add the new extracted node to your path.
nano ~/.profile
Add the following lines to the end:
# NodeJS
export NODEJS_HOME=/{path_to_the_extracted_folder}/node-v15.6.0-linux-x64/bin
export PATH=$NODEJS_HOME:$PATH
Please make sure you change {path_to_the_extracted_folder} to the path where you extracted the compressed file in the previous step.
Finally you can click CTRL+C to exit nano, type y then click enter.
To refresh the profile file enter the below code
. ~/.profile
Finally
To make sure everything is working fine check the nodeJs version by entering this command node -v it has to print v15.6.0.
You will not have to worry about the previously installed node version since above steps will change the nodeJs path.
I am having trouble using grunt in my projects. I am setting up an macos computer with version 11.0.1.
The project files (local) are in principle correct, since I use it on another computer and it works fine there.
I have been trying to solve this error for more than two days, the problem is that the local configuration does not work correctly, since I get the message ~ bash: grunt command not found when trying to initialize grunt with the grunt or grunt watch command
When trying to install grunt-cli globally I get this error:
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /Users/bertanicolau/.npm-packages
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/Users/bertanicolau/.npm-packages'
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! /Users/bertanicolau/.npm/_logs/2020-11-23T17_06_23_295Z-debug.log
The .npm-packages folder does not exist in this location, instead the .npm folder does exist, I don't know why it is looking for another.
I've tried clearing the npm cache, I've also tried deleting the package-lock.json file and changing paths on .bash-profile but none of this seems to work.
Can it be a npm or node version bug?
$ npm -v && node -v
7.0.8
v15.2.1
Thanks!
In one of your .npmrc files, you probably have prefix=/Users/trott/.npm-packages. If so, leave it and create the directory with mkdir ~/.npm-packages. Or set it to a different directory. Or remove the entry entirely.
The places to look for the .npmrc file that may be causing this to happen:
per-project config file (/path/to/my/project/.npmrc)
per-user config file (~/.npmrc)
global config file ($PREFIX/etc/npmrc)
npm builtin config file (/path/to/npm/npmrc)
I need start the project https://github.com/oracle/bots-node-sdk and I don`t know a lot of node.js. I try follow the instructions, but I receive the errors.
npm install #oracle/bots-node-sdk
npm ERR! code ENOSELF
npm ERR! Refusing to install package with name "#oracle/bots-node-sdk" under a package
npm ERR! also called "#oracle/bots-node-sdk". Did you name your project the same
npm ERR! as the dependency you're installing?
npm ERR!
npm ERR! For more information, see:
npm ERR! <https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\josiv\AppData\Roaming\npm-cache\_logs\2019-02-05T16_16_57_042Z-debug.log
I already try change name in file package.json and also I try command: npm init "other_name" and always the same error.
Edit:
I change name in file package.json and run npm install #oracle/bots-node-sdk. After run npx #oracle/bots-node-sdk init with successful:
---------------------------------------------------------------------
Custom Component package 'bots-node-sdk-master' created successfully!
---------------------------------------------------------------------
Usage:
npm start Start a dev server with the component package
PS D:\Fontes\OracleDigitalAssistant-Bot\bots-node-sdk-master> npm start
> bots#2.1.3 start D:\Fontes\OracleDigitalAssistant-Bot\bots-node-sdk-master
> npm run bots-node-sdk -- --service .
> bots#2.1.3 bots-node-sdk D:\Fontes\OracleDigitalAssistant-Bot\bots-node-sdk-master
> bots-node-sdk "--service" "."
It is saying there's a conflict with your project name and the dependency you're trying to install.
In your package.json, if the name property is "#oracle/bots-node-sdk" then change it to someone else and then run npm install #oracle/bots-node-sdk again.
Alternatively you can just delete the package.json file and then run npm init -y.
npm start
npm ERR! path C:\WINDOWS\System32\WindowsPowerShell\v1.0\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\WINDOWS\System32\WindowsPowerShell\v1.0\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! C:\Users\ATUL\AppData\Roaming\npm-cache\_logs\2017-10-01T10_20_21_068Z-debug.log
I am following the Wes-bos tutorial of learn-node. When I do npm start, it gives me these errors. Please help me. I have referred to all the previous questions. I am not able to find anything.
You have to run npm start in the root of the project you want to run, it seems you are runing npm start in a folder where there is not a package.json file.
The error says that you are running npm start in this path C:\WINDOWS\System32\WindowsPowerShell\v1.0\package.json but it seems that inside that folder you don't have a package.json file, so maybe you are in a wrong folder location.
So, if you downloaded some code to get started with, you should move to the root of that code and then run npm start.
If you are starting a new app, you have to run npm init first, that command will create a package.json file in the same location where you are in the console and then you will be able to run npm start.
I just had the same problem, so far I have never seen it.
But my solution was:
Rename the project folder (remove [], (), {} and special characters). Also try to remove spaces between words and if you continue the error try to join or just use (- or _) instead of space
Keep an eye on which folder is being performed. "When I didn't run: npm init -y" he would throw me to (C: \ WINDOWS \ System32 \ WindowsPowerShell \ v1.0 \ package.json), you don't want to run here,
use your project folder, change in the terminal to your folder: cd './c:\user\...\project'
Note: Solution tested in Windows - Visual Studio Code v1.56.0
nodejs vs-code visual-studio-code npm