Stuck on npm error - node.js

I am using Homestead on Windows 10 and suddenly as I added a package ran into an issue of npm being broken, for lack of a better word.
There is some kind of problem with node-sass (included with laravel-mix), but I am not sure what.
The error is:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass#4.7.2 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#4.7.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
This is preceeded by:
node-sass#4.7.2 install /home/vagrant/code/homestead/node_modules/node-sass
node scripts/install.js
fs.js:646
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EINVAL: invalid argument, open '/home/vagrant/code/homestead/node_modules/node-sass/package.json'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at Object.Module._extensions..json (module.js:669:20)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/vagrant/code/homestead/node_modules/node-sass/lib/extensions.js:7:9)
at Module._compile (module.js:652:30)
I have tried deleting node_modules folder to build it from scratch. It also runs into a symlink error, so I am running npm install with the --no-bin-links option
I am not sure what else to do. I have found nothing on Google so far to help me.
This is a snippet from the logs:
1975 verbose lifecycle node-sass#4.7.2~install: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/vagrant/code/homestead/node_modules/node-sass/node_modules/.bin:/home/vagrant/code/homestead/node_modules/.bin:/home/vagrant/.composer/vendor/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
1976 verbose lifecycle node-sass#4.7.2~install: CWD: /home/vagrant/code/homestead/node_modules/node-sass
1977 silly lifecycle node-sass#4.7.2~install: Args: [ '-c', 'node scripts/install.js' ]
1978 silly lifecycle node-sass#4.7.2~install: Returned: code: 1 signal: null
1979 info lifecycle node-sass#4.7.2~install: Failed to exec install script
To add:
I have also cleared npm cache (verified and even force cleared), provisioned Homestead several times. This is also actually a new box since the last one refused to come up so I replaced it completely. One of the more recent commands I ran was:
npm audit fix
Could that have broken it? I ran the install on my Windows host on the same folder and it worked without issues. After that it seems the install also works on Homestead. There are a lot of rollbacks but no specific errors anymore. I am still however at a loss as to what went wrong. I should not have to use a Windows machine to correct Linux mistakes.
And to edit again: while running install no longer introduced any errors, I still cannot run it. It doesn't run on Homestead/Linux nor on Windows. So I am still stuck.

Related

Not able to start react application - ENOENT: no such file or directory, but its NOT package.json file(The file is present)

I am new to react and I was following the official documentation in order to create my first react app - https://reactjs.org/docs/create-a-new-react-app.html
The commands are simple, I have read many post in many forums but I didn't see someone having this problem.
So I installed node.js with version 14.18.0 LTS which is OK as per the documentation in react (Node >= 14.0.0 and npm >= 5.6). Then I ran the 3 commands again from the documentation:
npx create-react-app my-app
cd my-app
npm start
First two commands are executed successfully, but when I run npm start it fails with the following error:
$ npm start
> my-app#0.1.0 start F:\Programming\my_location\my-app
> react-scripts start
internal/fs/utils.js:259
throw err;
^
Error: ENOENT: no such file or directory, lstat 'C:\Users\streetzaki96\AppData\Local\Temp;F:'
at Object.realpathSync (fs.js:1646:7)
at Object.<anonymous> (F:\Programming\my_location\my-app\node_modules\temp-dir\index.js:9:13)
at Module._compile (internal/modules/cjs/loader.js:1185:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
at Module.load (internal/modules/cjs/loader.js:1034:32)
at Function.Module._load (internal/modules/cjs/loader.js:923:14)
at Module.require (internal/modules/cjs/loader.js:1074:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (F:\Programming\my_location\my-app\node_modules\tempy\index.js:5:17)
at Module._compile (internal/modules/cjs/loader.js:1185:30) {
errno: -4058,
syscall: 'lstat',
code: 'ENOENT',
path: 'C:\\Users\\streetzaki96\\AppData\\Local\\Temp;F:'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#0.1.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! C:\Users\streetzaki96\AppData\Roaming\npm-cache\_logs\2021-10-05T21_31_51_222Z-debug.log
The machine which I am trying to run the code is with Windows 8.1 Pro. I also tried running the same commands on another machine which is with Windows 10 and I don't get any error there.
I tried running npm with verbose npm start --verbose to see if I can see something in the log file, but it is the same error message just with more lines of code.

How to properly set up dev environment using node and npm for Material.io components?

I've done the codepens provided by Material.io however when I try to follow the same steps using my own files, I always get an error.
> webpack-dev-server --progress
internal/modules/cjs/loader.js:983
throw err;
^
Error: Cannot find module 'webpack/bin/config-yargs'
Require stack:
- C:\Users\willy\Desktop\Wireframes-master\Front Page\node_modules\webpack-dev-server\bin\webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (C:\Users\willy\Desktop\Wireframes-master\Front Page\node_modules\webpack-dev-server\bin\webpack-dev-server.js:54:1)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\willy\\Desktop\\Wireframes-master\\Front Page\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mdc-101-web#0.0.0 start: `webpack-dev-server --progress`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mdc-101-web#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! C:\Users\willy\AppData\Roaming\npm-cache\_logs\2020-04-10T15_13_14_365Z-debug.log
C:\Users\willy\Desktop\Wireframes-master\Front Page>webpack-dev-server --progress
'webpack-dev-server' is not recognized as an internal or external command,
operable program or batch file.
I am still new to web development and most of this log is alien to me, I've found similar issues online however their solutions have not fixed my issue.
Versions:
npm: 6.14.4
webpack: 4.42.1
node.js: 12.16.2
UPDATE: It seems that when I first install npm, everything goes just fine, however there a 3 original vulnerabilities. Before I audit fix them, the npm start command works just fine and successfully compiles. When I run the npm audit to see the details of the vulnerabilities, I use the suggested commands to fix them. Once I've done that it no longer works.

JS-libp2p Tutorial Doc "Error: Cannot find module 'libp2p'"

I wanted to start learning to use libp2p and so started up the tutorial documentation and have hit a problem right away.
The Docs: https://docs.libp2p.io/tutorials/getting-started/javascript/
Following along I got to the "Run Libp2p" header. Running the script I get the error message Error: Cannot find module 'libp2p'
When install the module with sudo npm install libp2p there was an error reading:
ursaNative bindings compilation fail. This is not an issue. Modules that depend on it will use fallbacks.
fs.js:115
throw err;
^
Error: EACCES: permission denied, open './stdout.log'
at Object.openSync (fs.js:439:3)
at Object.writeFileSync (fs.js:1190:35)
at Object.<anonymous> (/home/foss/hello-libp2p/node_modules/ursa-optional/rebuild.js:13:10)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
npm WARN hello-libp2p#1.0.0 No description
npm WARN hello-libp2p#1.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ursa-optional#0.10.1 install: `node rebuild.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ursa-optional#0.10.1 install 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/2020-03-29T11_05_48_715Z-debug.log
`
I'm not really sure why there's a permission denied portion of the error as this was run as sudo.The problem seems to revolve around that ursa script. Although it might be optional I'm not sure. Does anyone who has worked with libp2p seen this before?
I'm using node12.16.1 and npm6.13.4 on ubuntu 19.10
Figured it out. Needed to, instead of running sudo npm i libp2p after manually installing the binaries, I had to just skip the sudo and it all works fine. This cause a problem though because I can't install modules globally now because using sudo throws the no npm command found.... I'm not too sure how to add the npm path back into the commands for sudo, or why npm is not present in sudo but is regularly.... This is strange. Will likely be resolved with other distros that natively support node v12 instead of v10. Hopefully 20.04lts will fix this.

Error when running vuetifyjs template

I have successfully installed a vuetifyjs template using the command
vue init vuetifyjs/webpack-advanced
it was successfully installed but when I tried to use the command npm run dev I had the following error message:
C:\Users\Muse\Documents\vuetify>npm run dev
vuetify#1.0.0 dev C:\Users\Muse\Documents\vuetify
node build/dev-server.js
fs.js:1657
binding.lstat(baseLong);
^
Error: ENOENT: no such file or directory, lstat 'C:\Users\Muse\Documents\vuetify\test'
at Object.realpathSync (fs.js:1657:15)
at resolve (C:\Users\Muse\Documents\vuetify\build\webpack.base.conf.js:8:13)
at Object. (C:\Users\Muse\Documents\vuetify\build\webpack.base.conf.js:35:35)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vuetify#1.0.0 dev: node build/dev-server.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vuetify#1.0.0 dev 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! C:\Users\Muse\AppData\Roaming\npm-cache_logs\2017-08-31T09_19_06_701Z-debug.log
You just need to create a test folder and give it access.
It's a bug with webpack-advanced template
Fore install your project dependencies
npm install -f
Then, make a folder named "test" in your root project
mkdir test
It's a bug caused by vuetifyjs/webpack-advanced

node-sass install failing on Jenkins

I'm trying to set up Jenkins to run Gulp but it keeps failing while attempting to install node-sass (a dependency of the gulp-sass plugin).
The issue seems to be that node is not finding a script file during install. I verified that script does actually exist in the project repository. When I pull my repo locally on the server and install it, it installs without a problem. That makes me think it's a Jenkins related environment issue.
Here's the error output:
> node-sass#2.1.1 install /root/.jenkins/jobs/odyssey-frontend/workspace/node_modules/gulp-sass/node_modules/node-sass
> node scripts/install.js
module.js:338
throw err;
^
Error: Cannot find module '/root/.jenkins/jobs/odyssey-frontend/workspace/node_modules/gulp-sass/node_modules/node-sass/scripts/install.js'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
npm ERR! Linux 3.14.35-28.38.amzn1.x86_64
npm ERR! argv "node" "/home/ec2-user/.linuxbrew/bin/npm" "install" "--production"
npm ERR! node v0.12.2
npm ERR! npm v2.7.6
npm ERR! code ELIFECYCLE
npm ERR! node-sass#2.1.1 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#2.1.1 install script 'node scripts/install.js'.
npm ERR! This is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node scripts/install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls node-sass
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /root/.jenkins/jobs/odyssey-frontend/workspace/npm-debug.log
module.js:338
throw err;
^
Error: Cannot find module 'gulp-sass'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/root/.jenkins/jobs/odyssey-frontend/workspace/gulpfile.js:11:12)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
Build step 'Execute shell' marked build as failure
Finished: FAILURE
The Linux distribution is Amazon Linux AMI, Fedora-like. Trying to install node-sass ^2.0.1 via gulp-sass ^1.3.3.
I just tried the updated gulp-sass 2.0.0 with node-sass 3.0.0 and still have the same issue.
I removed all node-sass dependencies and it builds successfully now. So its really just that package; all other node packages install successfully.
I posted this on the Github project where it was answered: https://github.com/sass/node-sass/issues/941#issuecomment-100414516
Jenkins seems to run everything as sudo when building. NPM, as a security feature, won't run install scripts as sudo, hence the error. Adding a --unsafe-perm flag to the install script gets by this issue.

Resources