At first I was getting the following error message on running npm run start inside my project directory.
npm err! code enoent
npm err! syscall spawn bash
npm err!
npm ERR! code ENOENT
npm ERR! syscall spawn bash
npm ERR! path C:\Users\naray\OneDrive\Desktop\Ananth\Courses\udemy - Node.js, Express, MongoDB & More The Complete Bootcamp 2022\complete-node-bootcamp-master\4-natours\starter-main
npm ERR! errno -4058
npm ERR! enoent spawn bash ENOENT
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\naray\AppData\Local\npm-cache\_logs\2023-02-03T10_29_53_655Z-debug-0.log
Then I ran npm install -g npm and now I cannot run any npm command. I keep getting the same error message (as shown below) for all npm commands.
node:internal/modules/cjs/loader:946
const err = new Error(message);
^
Error: Cannot find module '../package.json'
Require stack:
C:\\Users\\naray\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\cli.js
C:\\Users\\naray\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js
at Module.\_resolveFilename (node:internal/modules/cjs/loader:946:15)
at Module.\_load (node:internal/modules/cjs/loader:787:27)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at require (node:internal/modules/cjs/helpers:102:18)
at createEnginesValidation (C:\\Users\\naray\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\cli.js:7:15)
at module.exports (C:\\Users\\naray\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\cli.js:78:27)
at Object.\<anonymous\> (C:\\Users\\naray\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js:2:25)
at Module.\_compile (node:internal/modules/cjs/loader:1112:14)
at Module.\_extensions..js (node:internal/modules/cjs/loader:1166:10)
at Module.load (node:internal/modules/cjs/loader:988:32) {
code: 'MODULE_NOT_FOUND',
requireStack: \[
'C:\\Users\\naray\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\cli.js',
'C:\\Users\\naray\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js'
\]
}
I even tried running npm cache clean --force but got the same message.
Can anyone please help me resolve this?
Related
I am trying to test sensors using html and javascript like it's shown here but when I try to install polymer as it's written in the readme I get this error:
kupu#kupu:~/Dropbox/IOT/generic-sensor-demos/sensor-info$ npm install -g polymer-cli
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kupu/.npm/_logs/2020-05-09T17_52_32_877Z-debug.log
And even if I try to run it as sudo I get this:
kupu#kupu:~/Dropbox/IOT/generic-sensor-demos/sensor-info$ sudo npm install -g polymer-cli
/usr/local/bin/polymer -> /usr/local/lib/node_modules/polymer-cli/bin/polymer.js
> wd#1.11.2 install /usr/local/lib/node_modules/polymer-cli/node_modules/wd
> node scripts/build-browser-scripts
/usr/local/lib/node_modules/polymer-cli/node_modules/mkdirp/index.js:90
throw err0;
^
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/polymer-cli/node_modules/wd/build'
at Object.mkdirSync (fs.js:753:3)
at sync (/usr/local/lib/node_modules/polymer-cli/node_modules/mkdirp/index.js:71:13)
at Object.<anonymous> (/usr/local/lib/node_modules/polymer-cli/node_modules/wd/scripts/build-browser-scripts.js:6:1)
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 optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.9 (node_modules/polymer-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wd#1.11.2 install: `node scripts/build-browser-scripts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wd#1.11.2 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-05-09T17_53_02_303Z-debug.log
Is there a good soul out there that can help me?
You're having a typical npm EACCES permission issue. It has to do with your user not having permissions to modify the directory where npm is trying to store global packages. It can be very annoying. You should look here and see which solution fits you best: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
You can fix it with,
sudo npm install --unsafe-perm -g polymer-cli
Unsafe-perm flag is set to true to suppress User Identifier/ Group Identifier switching when running package scripts.The flag is explicitly set to false to prevent non-root user from installing packages.
You can also try to change ownership of node_modules,
To change ownership to current user as group -
sudo chown -R root: <YOUR_USERNAME>/usr/local/lib/node_modules/
sudo chmod -R 775 /usr/local/lib/node_modules/
And never use sudo for npm related query.
I get this error while doing an npm start:
PS C:\Users\Concierge\downloads\prod\pdf2\ipfs_image_uploader> npm start
> react-box#0.1.0 start C:\Users\Concierge\downloads\prod\pdf2\ipfs_image_uploader
> node scripts/start.js
internal/modules/cjs/loader.js:582
throw err;
^
Error: Cannot find module 'dotenv'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:\Users\Concierge\downloads\prod\pdf2\ipfs_image_uploader\scripts\
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-box#0.1.0 start: `node scripts/start.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-box#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output ab
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Concierge\AppData\Roaming\npm-cache\_logs\2018-11-17T04_27_59_461Z-debug
PS C:\Users\Concierge\downloads\prod\pdf2\ipfs_image_uploader>
and when I run command npm install, I get this error:
> scrypt#6.0.3 preinstall /Users/user/Documents/pdfuploader/node_modules/scrypt
> node node-scrypt-preinstall.js
> scrypt#6.0.3 install /Users/user/Documents/pdfuploader/node_modules/scrypt
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "/path/to/executable/python2.7", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! stack at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:68:16)
gyp ERR! stack at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/isexe/index.js:42:5
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/user/Documents/pdfuploader/node_modules/scrypt
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN ajv-keywords#3.2.0 requires a peer of ajv#^6.0.0 but none is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt#6.0.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the scrypt#6.0.3 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! /Users/user/.npm/_logs/2018-11-18T05_45_00_864Z-debug.log`
I tried to set up the pythonpath like here: https://www.tutorialspoint.com/How-to-set-your-python-path-on-Mac but it didn't help
I just sort it out by using this tutorial to insert that path /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages :
https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/
but then again i got that error when npm run start: `users-Air:pdfuploader user$ npm run start
client#0.1.0 start /Users/user/Documents/pdfuploader
react-scripts start
Could not find a required file.
Name: index.html
Searched in: /Users/user/Documents/pdfuploader/public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client#0.1.0 start: react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client#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! /Users/user/.npm/_logs/2018-11-18T06_44_50_004Z-debug.log`
Files which i am trying to npm run start:
https://github.com/damianjnc/pdfuploader
Some of the nodeJS modules are written in c++, and need to be compiled when being installed. This process requires python2 to be installed. Now, most Macs actually have python2 installed by default, but 'python' might not be on your executables path yet.
On a Mac, the python application is typically located at /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7. If there is no 'Python.framework' folder in /System/Library/Frameworks/ you will need to install python. If it is there, then simply symlink the previously mentioned python2.7 executable in /usr/bin. Also ensure that /usr/bin is present on your executable path by typing echo $PATH on your terminal.
To create a symlink run:
cd /usr/bin
sudo ln -s /path/to/original/python python
When i run my first react app using npm start command some error is displayed. Please some one help me to resolve this issue.
C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\bin\webpack-dev-server.js:386
throw e;
^
Error: `output.path` needs to be an absolute path or `/`.
at Object.setFs (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-middleware\lib\Shared.js:88:11)
at Shared (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-middleware\lib\Shared.js:214:8)
at module.exports (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-middleware\middleware.js:22:15)
at new Server (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\lib\Server.js:56:20)
at startDevServer (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\bin\webpack-dev-server.js:379:12)
at processOptions (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\bin\webpack-dev-server.js:317:3)
at Object.<anonymous> (C:\Users\ankit\Desktop\r3\node_modules\webpack-dev-server\bin\webpack-dev-server.js:441:1)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
npm ERR! Windows_NT 6.2.9200
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v7.5.0
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! r3#1.0.0 start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the r3#1.0.0 start script 'webpack-dev-server'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the r3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack-dev-server
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs r3
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls r3
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\ankit\Desktop\r3\npm-debug.log
The error message is clear: output.path needs to be an absolute path or /
Your output.path should write like this:
var path = require('path');
output: {
path: path.join( __dirname, './dist/'),
}
I'm trying to encode a NetCDF file in Node.js program, by using the netcdf(https://www.npmjs.com/package/netcdf) library.
Now, once I run a program, I get an error below.
C:\app [master +2 ~1 -0 !]> npm start
> spaceapps#1.0.0 start C:\app
> node server.js
C:\app\node_modules\text-encoding\lib\encoding.js:979
throw TypeError('Called as a function. Did you forget \'new\'?');
^
TypeError: Called as a function. Did you forget 'new'?
at TypeError (native)
at Object.TextDecoder (C:\app\node_modules\text-encoding\lib\encoding.js:979:13)
at Object.<anonymous> (C:\app\node_modules\netcdf\util\readbinary.js:4:40)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\app\node_modules\netcdf\util\type.js:4:14)
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files (x86)\\Nodist\\v\\nodev5.9.1\\node.exe" "C:\\Program Files (x86)\\Nodist\\bin\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v5.9.1
npm ERR! npm v3.8.7
npm ERR! code ELIFECYCLE
npm ERR! spaceapps#1.0.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the spaceapps#1.0.0 start script 'node server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the spaceapps package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs spaceapps
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls spaceapps
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\app\npm-debug.log
C:\app [master +3 ~1 -0 !]>
It seems there is an error in a library.
I appreciate if someone tells me a solution for it.
As the developer said, He has no plans in the short or medium term to continue development, so you could consider use netcdfjs, that it's a javascript library that allows to read NetCDF v3 files. Because it's a NodeJS package you can run it server side, and for regular size files you can read it online, here you have an example.
I am getting a very odd error trying to install the express-generator with and without sudo.
I need to run: npm install express-generator -g and then express --ejs name_here but when executing the first command, I get the following error:
npm ERR! Darwin 15.2.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "express-generator" "-g"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! path /Users/[name]/.npm/lib/node_modules/express-generator/LICENSE
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, unlink '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, unlink '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES, unlink '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE'
npm ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EACCES, unlink '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE']
npm ERR! error rolling back errno: -13,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE' }
npm ERR! Please include the following file with any support request:
npm ERR! /Users/[name]/Documents/Projects/MEAN Stack Tutorial/npm-debug.log
After trying sudo npm install express-generator -g I get this:
/Users/[name]/.npm/bin/express -> /Users/[name]/.npm/lib/node_modules/express-generator/bin/express
express-generator#4.13.1 /Users/[name]/.npm/lib/node_modules/express-generator
├── sorted-object#1.0.0
├── commander#2.7.1 (graceful-readlink#1.0.1)
└── mkdirp#0.5.1 (minimist#0.0.8)
Then running express --ejs name_here returns -bash: express: command not found
Is there a way I can solve this issue? The other questions on SO seem to have fixed the issue by trying sudo but not for me.
Try to use an express command with a full path: /Users/[name]/.npm/bin/express or sudo /Users/[name]/.npm/bin/express.
Looks like PATH variable wasn't set after installation. (https://en.wikipedia.org/wiki/PATH_(variable))