Module not found: Error: Package path ./lib/index is not exported from package /node_modules/highlight.js - module

I'm using Laravel, When I run npm run dev, it shows this:
ERROR in ./resources/assets/vendor/libs/highlight/highlight.js 4:0-42
Module not found: Error: Package path ./lib/index is not exported from package /home/wwwroot/myproject/node_modules/highlight.js (see exports field in /home/wwwroot/myproject/node_modules/highlight.js/package.json)
I checked /home/wwwroot/myproject/node_modules/highlight.js and there is ./lib/index.js
I've changed these in myproject before running npm run dev with root, but nothing changed:
chmod 775 myproject -R
chown www:www -R myproject

Related

Can't remove file based variables

It looks like this error output from gitlab runner isn't well documented on the Internet so far so I'm starting a topic. Error output:
Step 11/13 : RUN chown -R node /usr/src/app/node_modules
---> Running in d9cb1a93d908
WARNING: Error while executing file based variables removal script error=context canceled job=1 project=0
ERROR: Failed to cleanup volumes
ERROR: Job failed: execution took longer than 30m0s seconds
FATAL: execution took longer than 30m0s seconds
this is coming from gitlab runner installed locally on Ubuntu machine.
Any suggestions as to how to troubleshoot this error ?
Dockerfile:
FROM node:16-alpine
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH
COPY package.json /usr/src/app/package.json
COPY package-lock.json /usr/src/app/package-lock.json
RUN mkdir /usr/src/app/node_modules
RUN mkdir /usr/src/app/node_modules/.cache
RUN npm config set unsafe-perm true # to avoid permission problems when accessing .cache dir later on
RUN npm ci --loglevel=error
RUN npm i -g --silent --loglevel=error
RUN chown -R node /usr/src/app/node_modules
USER node
CMD ["npm", "start"]
I don't think this is related to gitlab, you are overwriting the owner of every dependency in your project, with nodejs those tend to grow exponentially.
You didn't post your Dockerfile, but this would be a matter of just rewriting in the following way:
FROM node:16-alpine
ENV PATH /home/node/app/node_modules/.bin:$PATH
# Create a directory for the project, change the owner and group
# to it, but do this before installing anything in the node_modules
# directory, to avoid timeouts.
RUN mkdir -p /home/node/app/node_modules \
&& mkdir -p /home/node/app/node_modules/.cache \
&& chown -R node:node /home/node/app
# Change to a workdir that can be owned by the 'node' user
WORKDIR /home/node/app
# Copying the lockfiles to make them cached by Docker,
# also sets the right permissions at the same time
COPY --chown=node:node package*.json ./
# to avoid permission problems when accessing .cache dir later on
RUN npm config set unsafe-perm true
RUN npm ci --loglevel=error \
&& npm i -g --silent --loglevel=error
# Now, change to the node user and install your deps
USER node
# Copy the remaining files and make sure to set the user/group
# right, to avoid permission issues
COPY --chown=node:node . .
RUN npm install
CMD ["npm", "start"]

Gulp installation errors on terminal

When I install gulp using npm install gulp-cli -g
It shows me an error in the picture below. Can someone help me?
I have tried to change administrator access and delete node_modules in my hard drive, but it still shows me errors
When you install packages globally, by default, npm will install them in /usr/local/lib/node_modules which requires
root permissions.
There are 3 solutions to your problem:
Install the package as root user
sudo npm install -g gulp-cli
Change the owner of /usr/local/lib/node_modules
sudo chown -R your_user_name: /usr/local/lib/node_modules
Recommended: Manually change npm’s default directory
In your home directory, create a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
In your preferred text editor, open or create a ~/.profile file and
add this line:
export PATH=~/.npm-global/bin:$PATH
On the command line, update your system variables:
source ~/.profile
To test your new configuration, install a package globally without using sudo:
npm install -g gulp-cli

Local npm module cannot be found

In a React Boilerplate project, I am trying to use a local module, but getting:
ERROR in ./node_modules/react-sortable-tree-theme-file-explorer/dist/main.js
Module build failed: Error: ENOENT: no such file or directory, open '/Users/username/Documents/project/node_modules/react-sortable-tree-theme-file-explorer/dist/main.js'
Both paths do exist:
$ ls node_modules/react-sortable-tree-theme-file-explorer/dist/main.js
node_modules/react-sortable-tree-theme-file-explorer/dist/main.js
and
$ ls /Users/username/Documents/project/node_modules/react-sortable-tree-theme-file-explorer/dist/main.js
/Users/username/Documents/project/node_modules/react-sortable-tree-theme-file-explorer/dist/main.js
...so I can't figure out what the complaint is. The paths and files DO EXIST. I used npm link initially, but that never worked, and so I also tried npm install ../react-sortable-tree-theme-file-explorer but it gives the exact same results.
I am importing the package as in:
import FileExplorerThemeBase from "react-sortable-tree-theme-file-explorer";

react-native: command not found in ubuntu 18.04

I am trying running react-native from last 2 days but I am not able to run anything ,I followed official page for getting started and followed instructions carefully but everytime terminal gives me this error
npm -v 6.9.0
node -v v12.6.0
java -version
openjdk version "1.8.0_212"
these are the versions of requirements i have installed
I copy pasted
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
these inside of .bashrc file in home
can anyone save me please
React Native site has good installation guide for React Native CLI on Linux, but sometimes command npm install -g react-native-cli fails with error
checkPermissions Missing write access to /usr/lib/node_modules
because only root can access directory where NPM install global packages. You might want to run sudo npm install -g react-native-cli but you shouldn`t.
(If you did it, run please:
sudo chown -R $(whoami) ~/.npm
to eliminate consequences).
The most preferred solution will be changing npm’s default directory:
create a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
Open ~/.bashrc (or ~/.profile) file and add this line:
export PATH=~/.npm-global/bin:$PATH
On the command line, update your system variables:
source ~/.bashrc
Now you can install react-native-cli globally without using sudo:
npm install -g react-native-cli.
After that react-native init should work.

Problem with installing and running aws-amplify cli and global npm packages in general

I'm trying to install the aws amplify cli on my Mac. It seems to install ok, but when i run it afterwards is responds with
bash: amplify: command not found
I was thinking that it probably had something to do with the directory of the global npm packages, so i ran
$ npm -g root
Which returned:
/usr/local/lib/node_modules/node/lib/node_modules
It seems very odd that my node_modules are placed inside another node modules folder.
When i run:
$ which npm
it returns:
/usr/local/bin/npm
I also tried listing my global packages with the command
$ npm list -g --depth=0
Which returned:
/usr/local/lib/node_modules/node/lib
├── #angular/cli#7.3.1
├── #aws-amplify/cli#1.5.1
├── ng#0.0.0
├── npm#6.9.0
├── npm-check#5.9.0
├── tsc#1.20150623.0
├── typeorm#0.2.16
└── typescript#3.2.2
Can somebody please help me sort this mess out?
I ran into the same issue following the AWS Tutorial for deploying a React App: https://aws.amazon.com/getting-started/hands-on/build-react-app-amplify-graphql/module-two/
I used the command below as stated in the tutorial to install the Amplify CLI:
npm install -g #aws-amplify/cli
The packages installed successfully but after moving to the next step of the tutorial I got the same error:
amplify: command not found
The issue was the package was being installed outside my path and could not be found. However running the curl command below added the necessary line to my zshrc file and configured my $Path correctly.
curl -sL https://aws-amplify.github.io/amplify-cli/install | bash && $SHELL
(https://docs.amplify.aws/cli/start/install)
This is the result of running the curl command above
The line below was automatically added to my .zshrc file:
# Added by Amplify CLI binary installer
export PATH="$HOME/.amplify/bin:$PATH"
In case if someone is installing amplify using curl on Mac, then you need to edit your .zprofile (if you are using zsh terminal) or .bash_profile.
Open your terminal
1. cd
2. vim .zprofile
3. Press i, then paste this line
export PATH="$HOME/.amplify/bin:$PATH"
4. Press Esc and :wq to save this file
5. Restart your terminal