i was created docker file, and when I am runing the image , I have a error "Error: Cannot find module 'mobilePath"
The package.json :
"_moduleAliases": {
"apiPath": "./api.js",
"sourcesPath": "./sources.js",
"mobilePath": "./test/Mobile.js"
}
docker file :
FROM node:14.15.3-buster
RUN npm install -g npm#latest
RUN npm --version
RUN npm install -g yarn#latest --force
RUN yarn --version
RUN apt-get update
RUN apt-get install -y fonts-liberation libappindicator3-1 xdg-utils
RUN mkdir -p /usr/src/app/ccv
WORKDIR /usr/src/app/ccv
COPY package*.json .
RUN npm install
COPY . /usr/src/app/ccv
RUN chmod +x suites/script.sh
ENTRYPOINT ["suites/script.sh"]
in local is working fine, why docker image cannot find _moduleAliases?
As per the yarn installation for yarn v2, they want you to install using npm install -g yarn. So I ran sudo npm install -g yarn on Ubuntu 20.04. But after I do that, it says command not found.
❯ sudo npm install -g yarn
> yarn#1.22.10 preinstall /usr/local/lib/node_modules/yarn
> :; (node ./preinstall.js > /dev/null 2>&1 || true)
❯ yarn --version
zsh: command not found: yarn
sudo npm install -g npm
then
sudo npm install -g yarn
Then reboot your system. That did it for me.
Before a reboot only sudo yarn worked. I tried looking at file permissions but everything seemed in order and the files were executable as expected. Nevertheless after a reboot it worked.
If you go to /usr/local/bin after the installation there's a link there to where yarn.js lives, as expected, and file permissions for it were also correct.
/usr/local/bin is added to $PATH, so it's surprising that it doesn't see the new cmd right away, but perhaps it didn't reload or map it until after the reboot? I don't know. But I just spent a good hour trying to figure this out so I'm posting what worked for me to spare other the hassle.
TL;DR
If you are managing node via nvm, then probably the path to yarn binary is not included in the $PATH variable. You should add this -
# Add this at the end (or after the $NVM_DIR initialization)
# in your profile - .bashrc | .zshrc | .profile, etc
export PATH="`yarn global bin`:$PATH"
at the end of your profile file (.zshrc for me) or at least after the $NVM_DIR initialization.
I have recently faced this issue and while searching for a solution, I landed up here.
Here is what my environment looks like:
OS: Ubuntu 20.04
Shell: zsh
NodeJS: managing it via nvm, and NOT apt.
After going through all the answers, I was not keen on uninstalling anything. So I tried to dig a bit deeper.
I installed yarn via npm install -g yarn command. So the first thing I wanted to verify was the location of the yarn binary. To do this, I ran the command where yarn which lists the installation path for the yarn binary.
$ where yarn
/home/<user_name>/.nvm/versions/node/v16.11.1/bin/yarn
Then it hit me. In my .zshrc file, I had added the yarn global bin command (which spills out the directory of all the global packages installed by yarn) at the top like so:
# Top of my .zshrc file
export PATH="`yarn global bin`:$HOME/bin:/usr/local/bin:$PATH"
and as per the installation instruction of nvm, the $NVM_DIR (the variable which holds the nvm directory path) was added at the end of my .zshrc file.
So when I was starting up my shell, it was actually trying to load the yarn command (present inside the nvm directory) even before loading the $NVM_DIR path.
To solve this, I tweaked my .zshrc file and moved the yarn global bin command after the $NVM_DIR like this:
# Top of my .zshrc file
export PATH="$HOME/bin:/usr/local/bin:$PATH"
# ...
#
# Something in between
#
# ...
# Bottom of my .zshrc file
export NVM_DIR="${HOME}/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# Here is where I have added the path to yarn global
export PATH="`yarn global bin`:$$PATH"
I hope that this would be of help.
This solved it for me:
corepack enable
(if you get "Internal Error: EACCES: permission denied", run it with sudo)
This is also recommended by the Yarn documentation: https://yarnpkg.com/getting-started/install
Uninstall cmdtest:
sudo apt remove cmdtest
Then, run these commands:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn
If you want to avoid reboot, use
/usr/local/lib/node_modules/yarn/bin/yarn --version
The yarn documentation is missing a step, you need to restart your computer between this installation and running yarn --version.
This worked for me
I recently had a similar situation and here is how I solved it.
First I troubleshoot the current npm installation:
npm config -list
I had a ~/.npmrc file that had a different prefix:
PREFIX=/opt/homebrew
That made my npm installation look for globally installed packages under /opt/homebrew.
In my case, I'm using a different npm installation (not with homebrew anymore). A simple fix is to remove this custom PREFIX from the ~/.npmrc file and the problem was solved.
Now npm looks for globally installed packages under /usr/local/bin/.
I installed yarn with npm install -g yarn on git bash and I tested it with yarn -v that show the version of the installed yarn, but when I used yarn start it gives me this error
C:\Users\{username}\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found
These are simple steps that I used to fix my problem on Windows 10:
Uninstall node.js
Restart your computer
Delete your C:\Program Files\nodejs and C:\Users\{username}\AppData\Roaming\npm
Install node.js again and check it with node -v
Start your vs code as an admin and write npm install
Write yarn start
Install Lumber
npm install -g lumber-cli -s
then,
lumber generate "adminpanel_test" --connection-url "mysql://root#localhost:3306/admin-dev" --ssl "false" --application-host "localhost" --application-port "3310"
lumber is not recognized as an internal or external command
lumber-cli is not installed properly on your shell.
If you run this you can see the reason why it is stop installing.
npm install -g lumber-cli
Sometimes it can work if you are working on local env.
sudo npm install -g lumber-cli
You can also try to install it locally:
$ npm install —save-dev lumber-cli
I want to install a newest version of NodeJS on Ubuntu Zesty 17.04. But whether using apt-get or trying to download it from nodesource ppa, I always have the version 4.7.2.
Apt-get
sudo apt-get update
sudo apt-get install nodejs npm
Node PPA
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
sudo apt-get update
apt-get install nodejs npm
Result
$> node -v
v4.7.2
How can I get the version 6.9 of NodeJS ?
I didn't succeed to install it via apt-get or nodesource ppa. However I solved the problem by installing Node manually by following these steps :
Remove the old version sudo apt-get remove --purge node
Download Node binaries from https://nodejs.org/en/
Extract the archive where you want tar -xzf <ARCHIVE>.tar.gz -C <YOUR_FOLDER>
Create a node symbolic link ln -sf <YOUR_FOLDER>/bin/node /usr/bin/node
Create a nodejs symbolic link ln -sf <YOUR_FOLDER>/bin/node /usr/bin/nodejs
result :
radouane#roufid:$ node -v
v6.10.2
I hope it helps !
Best way is to use n. It is a node module that helps you to update and switch between node versions easily.
npm install n --global
n list will list all node versions.
If you want to switch to new version 6.10.2 use command
n 6.10.2
To install the NodeJS any version
# you can replace number 6 with new version
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
sudo apt install nodejs
node -v
This is my first time setting up a jenkins server. The build is using Amazon's EC2 and Ubuntu 14.04.
I've installed node and npm via nvm.
node -v
>v0.11.14
npm -v
>2.0.0
The repo pulls down just fine into my /var/lib/jenkins/workspace/morningharwood folder.
Problem: When I add my script it breaks
Here's my build script which errors out? I have no idea what i'm doing. I copied this from a tutorial.
QUESTION: How do I properly write my script to npm install, bower install and lastly, grunt test
You could install node, npm, bower and grunt by doing following:
sudo apt-get install node
sudo npm install bower
sudo npm install grunt
To install a package from local source, use
npm install /path
Try using NodeJS plugin for Jenkins: https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin
This will solve npm command not found issue on jenkins even installed on server
sudo mkdir /usr/local/nvm
export NVM_DIR=/usr/local/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh |NVM_DIR=/usr/local/nvm bash
. /usr/local/nvm/nvm.sh
nvm install 10.15.3 -g
npm install #angular/cli -g
Include following on build execute shell command in jenkins:
export PATH="$PATH:/usr/local/nvm/versions/node/v10.15.3/bin"
npm install