I installed npm before and work with many projects along with express.js , but today I opened a folder and willing to start a new project. But after npm init command , it says util.js module not found.
I found this util.js file on this root directory npm\node_modules\npm\node_modules.
How to solve this issue?
F:\Pulok\HabluTheGreatDoc\Projects\ReactApp\event-booking>npm init
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './util.js'
npm ERR! Require stack:
npm ERR! - C:\Users\Sabbir\AppData\Roaming\npm\node_modules\npm\node_modules\libnpx\index.js
npm ERR! - C:\Users\Sabbir\AppData\Roaming\npm\node_modules\npm\lib\init.js
npm ERR! - C:\Users\Sabbir\AppData\Roaming\npm\node_modules\npm\lib\npm.js
npm ERR! - C:\Users\Sabbir\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Sabbir\AppData\Roaming\npm-cache\_logs\2020-07-12T06_33_44_670Z-debug.log
Edit:
npm version: 6.14.5.
node.js version: v12.16.1
I have also tried running npm cache clean --force and npm init --yes, however I continue to get the same error message.
Related
So I've just created a NextJS project using create-next-app which went smoothly as expected. Then ran npm i just to be sure and saw all modules installed into node_modules
When I try to run npm run dev to start my nextjs app. it just says
sh: next: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! test#0.1.0 dev: `next dev`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the test#0.1.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! /Users/john.v.n.pakson/.npm/_logs/2022-10-06T08_01_29_725Z-debug.log
It seems like npm is not detecting the node_modules i have installed.
Not sure if this is a mac or a zsh issue.
I'm using node version 12.22.12
Upgraded to 16.17.1 and still see the same error
> test#0.1.0 dev
> next dev
/var/folders/6y/xtlzp4z16dj0stxnqx8znj8w0000gn/T/dev-01c08137.sh: line 1: next: command not found
Okay I figured it out. It was caused by my file path on macos. My project was on a folder called Project/Test which might have confused zsh or mac. This in turn caused npm to not be able to find the correct scripts on my node_modules
When I moved my project to another folder I was already able to run npm run dev properly.
Cheers!
I'm just dipping my toes into using Laravel for the first time, and I've had many issues so far. I've figured them out myself so far, but this one is driving me crazy!
After adding the line require('tailwindcss') in my webpack.mix.js file, I keep getting the following error when I run.
npm run dev
✖ Mix
Compiled with some errors in 452.52ms
ERROR in ./resources/css/app.css
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
TypeError: Cannot read property 'config' of undefined
at getTailwindConfig (/home/timothy/blog/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:81:62)
at /home/timothy/blog/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:124:92
at /home/timothy/blog/node_modules/tailwindcss/lib/processTailwindFeatures.js:41:11
at plugins (/home/timothy/blog/node_modules/tailwindcss/lib/index.js:20:104)
at LazyResult.runOnRoot (/home/timothy/blog/node_modules/postcss/lib/lazy-result.js:339:16)
at LazyResult.runAsync (/home/timothy/blog/node_modules/postcss/lib/lazy-result.js:393:26)
at LazyResult.async (/home/timothy/blog/node_modules/postcss/lib/lazy-result.js:221:30)
at LazyResult.then (/home/timothy/blog/node_modules/postcss/lib/lazy-result.js:206:17)
at processResult (/home/timothy/blog/node_modules/webpack/lib/NormalModule.js:751:19)
at /home/timothy/blog/node_modules/webpack/lib/NormalModule.js:853:5
at /home/timothy/blog/node_modules/loader-runner/lib/LoaderRunner.js:399:11
at /home/timothy/blog/node_modules/loader-runner/lib/LoaderRunner.js:251:18
at context.callback (/home/timothy/blog/node_modules/loader-runner/lib/LoaderRunner.js:124:13)
at Object.loader (/home/timothy/blog/node_modules/postcss-loader/dist/index.js:142:7)
1 ERROR in child compilations (Use 'stats.children: true' resp. '--stats-children' for more details)
webpack compiled with 2 errors
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # development: `mix`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # development 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! /home/timothy/.npm/_logs/2022-01-18T04_24_37_451Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # 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! /home/timothy/.npm/_logs/2022-01-18T04_24_37_460Z-debug.log
I've looked into my version of Node.js and PostCSS being an issue, as my version of node.js has been an issue that caused other problems I've had so far, but those two seem fine. If it matters, this is a Laravel project created with Composer on Ubuntu 20.04 with Laravel installer 4.2.9.
Just run this comman. Tailwind config file is missing.
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init
executing the npm install command in windows 10 machine .
facing the below issue
C:\ >npm install
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'read-package-tree'
npm ERR! Require stack:
npm ERR! - C:\Users\dineshkumars2\AppData\Roaming\npm\node_modules\npm\lib\install.js
npm ERR! - C:\Users\dineshkumars2\AppData\Roaming\npm\node_modules\npm\lib\npm.js
npm ERR! - C:\Users\dineshkumars2\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dineshkumars2\AppData\Roaming\npm-cache\_logs\2020-12-31T02_21_08_042Z-debug.log
Try installing read-package-tree using npm command as,
npm i read-package-tree
In case same error showing for executing the above command, Please copy the folder from another machine and paste it into the path that where node_modules are in.
Ex:
C:\Users\MyName\AppData\Roaming\npm\node_modules\npm\node_modules
then run the below command npm i read-package-tree it will resolve the issue, now we can able to run the command 'npm install'
In my project, I use Parcel to bundle everything. Now, I am at the point where I need to deploy my app.
I clone my git repo with my React app and I put in the Node server.
I tried every command possible to install parcel, but I always get the following error :
> pp-react#0.1.0 build /home/volodymk/react
> parcel build index.html
sh: parcel: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! pp-react#0.1.0 build: `parcel build index.html`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the pp-react#0.1.0 build 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! /home/volodymk/.npm/_logs/2020-01-12T19_26_22_634Z-debug.log
How can I fix this ?
To run any installed node package (not just Parcel), use npx, the utility command shipped with npm. It executes packages that come with a runtime command in your node_modules/packagename/.bin directories.
As in npx parcel build index.html
More information available in the npx readme.
When I was trying to deploy my node.js app (with both nodejitsu and heroku), I got the same errors with libxmljs.
> libxmljs#0.4.1 preinstall /root/tmp/tmp-31613c7bs0y8/build/package/node_modules/twilio/node_modules/libxmljs
> make node
make: scons: Command not found
make: *** [node] Error 127
npm http 200 https://registry.nodejitsu.com/css-stringify
npm http 200 https://registry.nodejitsu.com/css-parse
npm http 200 https://registry.nodejitsu.com/is-promise/-/is-promise-1.0.1.tgz
> libxmljs#0.4.1 preuninstall /root/tmp/tmp-31613c7bs0y8/build/package/node_modules/twilio/node_modules/libxmljs
> make clean
make: scons: Command not found
make: *** [clean] Error 127
npm http GET https://registry.nodejitsu.com/css-stringify/-/css-stringify-1.0.5.tgz
npm http GET https://registry.nodejitsu.com/css-parse/-/css-parse-1.0.4.tgz
npm WARN continuing anyway libxmljs#0.4.1 preuninstall: `make clean`
npm WARN continuing anyway Exit status 2
npm ERR! libxmljs#0.4.1 preinstall: `make node`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the libxmljs#0.4.1 preinstall script.
npm ERR! This is most likely a problem with the libxmljs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! make node
npm ERR! You can get their info via:
npm ERR! npm owner ls libxmljs
npm ERR! There is likely additional logging output above.
npm ERR! System SunOS 5.11
npm ERR! command "node" "/opt/local/bin/npm" "install" "--loglevel=http"
npm ERR! cwd /root/tmp/tmp-31613c7bs0y8/build/package
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.14
npm ERR! code ELIFECYCLE
As you can see, it is failing within libxmljs's 'make node' and 'make clean' as the command 'scons' is not found. I have libxmljs installed in my app's node_modules directory, and 'scons' is located at "/usr/local/bin/scons".
I believe I have to ensure that the location of scons is in the path for the make environment of libxmljs but I don't know how to do that. Any help would be appreciated!
UPDATE: Following the advice from this question (Fail to deploy node.js application to heroku) I added libxmljs to the dependencies in package.json and added node_modules/ to .gitignore, that way heroku could have a look at the dependencies and install them itself. However, the exact same error occurred, which leads me to believe the root of the problem is not with my local environment, but something larger regarding libxmljs?
I was able to resolve my problem, although it wasn't really specifically about libxmljs. I also used the 'twilio' node submodule in my app, but listed its version as '0.0.0' in dependencies. I guess twilio 0.0.0 used libxmljs which wouldn't install when deploying to heroku, so I updated the twilio version number to the actual current version, and everything's good to go!