Timeout trying to fetch resolutions from npm - node.js

I'm trying to install microsoft-cognitiveservices-speech-sdk
npm install microsoft-cognitiveservices-speech-sdk
but I keep encountering this error Timeout trying to fetch resolutions from npm
The solutions I'm finding on stackoverflow all point to adding a preinstall line to my package.json where I specify this "preinstall": "npx npm-force-resolutions#0.0.3" which would work fine if the microsoft-cognitiveservbices-speech-sdk didn't have the same line in its package.json where its trying to install the npm-force-resoultion in its preinstall without a version declared. So I guess is there an .npmrc config value I can set so I won't experience the timeout error (timeout=60000 didn't work)?
> microsoft-cognitiveservices-speech-sdk#1.21.0-alpha.0.1 preinstall
> npm install --package-lock-only --ignore-scripts --no-audit && npx npm-force-resolutions
up to date in 2s
98 packages are looking for funding
run `npm fund` for details
/home/woodsy/.npm/_npx/73b02210abc194ff/node_modules/npm-force-resolutions/out/npm_force_resolutions/core.cljs:61
(go
^
Error: Timeout trying to fetch resolutions from npm
at switch__2144__auto__ (/home/woodsy/.npm/_npx/73b02210abc194ff/node_modules/npm-force-resolutions/out/npm_force_resolutions/core.cljs:61:3)
at /home/woodsy/.npm/_npx/73b02210abc194ff/node_modules/npm-force-resolutions/out/npm_force_resolutions/core.cljs:61:3
at npm_force_resolutions$core$find_resolutions_$_state_machine__2145__auto____1 (/home/woodsy/.npm/_npx/73b02210abc194ff/node_modules/npm-force-resolutions/out/npm_force_resolutions/core.js:476:4)
at cljs.core.async.impl.ioc-helpers/FN-IDX (/home/woodsy/.npm/_npx/73b02210abc194ff/node_modules/npm-force-resolutions/out/npm_force_resolutions/core.js:492:85)
at cljs.core.async.impl.ioc-helpers/run-state-machine (/home/woodsy/.npm/_npx/73b02210abc194ff/node_modules/npm-force-resolutions/out/cljs/core/async/impl/ioc_helpers.cljs:35:23)
at cljs.core.async.impl.ioc-helpers/run-state-machine-wrapped (/home/woodsy/.npm/_npx/73b02210abc194ff/node_modules/npm-force-resolutions/out/cljs/core/async/impl/ioc_helpers.cljs:39:6)
at fret (/home/woodsy/.npm/_npx/73b02210abc194ff/node_modules/npm-force-resolutions/out/cljs/core/async.cljs:490:22)
at take-cb (/home/woodsy/.npm/_npx/73b02210abc194ff/node_modules/npm-force-resolutions/out/cljs/core/async.cljs:188:63)
at /home/woodsy/.npm/_npx/73b02210abc194ff/node_modules/npm-force-resolutions/out/cljs/core/async/impl/channels.cljs:160:45
at Immediate.cljs$core$async$impl$dispatch$process_messages (/home/woodsy/.npm/_npx/73b02210abc194ff/node_modules/npm-force-resolutions/out/cljs/core/async/impl/dispatch.cljs:18:7)
npm ERR! code 1
npm ERR! path /home/woodsy/cognitive-services-speech-sdk-js
npm ERR! command failed
npm ERR! command sh -c npm install --package-lock-only --ignore-scripts --no-audit && npx npm-force-resolutions

I am able to install the speech sdk on a default node#16.15.1 docker container.
The only trouble I had was figuring out the earlier version of the node docker contain require you to provide the --workdir parameter, or NPM will fail every install with a generic "IdealTree" error.
Are you able to use the following?
If not, what errors do you get?
C:\Users\brianem>docker run -it --rm --workdir /temp node:16.15.1 bash
root#1a4900f41d89:/temp# npm install microsoft-cognitiveservices-speech-sdk
added 44 packages, and audited 45 packages in 47s
9 packages are looking for funding
run npm fund for details
found 0 vulnerabilities
npm notice
npm notice New major version of npm available! 8.11.0 -> 9.2.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.2.0
npm notice Run npm install -g npm#9.2.0 to update!
npm notice
root#1a4900f41d89:/temp# head node_modules/microsoft-cognitiveservices-speech-sdk/package.json
{
"name": "microsoft-cognitiveservices-speech-sdk",
"author": "Microsoft Corporation",
"homepage": "https://docs.microsoft.com/azure/cognitive-services/speech-service/",
"version": "1.24.1",
"license": "MIT",
"description": "Microsoft Cognitive Services Speech SDK for JavaScript",
"keywords": [
"microsoft",
"cognitiveservices",
root#1a4900f41d89:/temp#

Related

When using npm, commands fail due to cache access restriction/lock (errno EBUSY -4082)

Problem
I've been running into what appears to be a directory access issue in Windows when attempting to use npm. Having tried numerous suggestions from various other SO questions and answers, I thought I'd see if anyone might have suggestions or solutions based on log the output.
I'm continuously running into the error anytime I attempt an npm operation, including install (global or local), uninstall, update, or executing tools such as electron-packager as shown in the package.json scripts section, below the error itself.
Information
Operating system: Windows 10 (Build 19043)
node version: v18.3.0
npm version: 8.12.1
The error output itself is typically
:
npm ERR! code EBUSY
npm ERR! syscall rename
npm ERR! path C:\Users\<username>\AppData\Local\npm-cache\_cacache\tmp\a870f111
npm ERR! dest C:\Users\<username>\AppData\Local\npm-cache\_cacache\content-v2\sha512\d3\23\a585f82ed54ccfe948a39da16e212d9b112d87f43f74100e4e56c7f688e670ed506b8e7b57284c0a7c268503abcc5569023fcaa73f00b1c4f7670d5c2537
npm ERR! errno -4082
npm ERR! EBUSY: resource busy or locked, rename 'C:\Users\<username>\AppData\Local\npm-cache\_cacache\tmp\a870f111' -> 'C:\Users\<username>\AppData\Local\npm-cache\_cacache\content-v2\sha512\d3\23\a585f82ed54ccfe948a39da16e212d9b112d87f43f74100e4e56c7f688e670ed506b8e7b57284c0a7c268503abcc5569023fcaa73f00b1c4f7670d5c2537'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\<username>\AppData\Local\npm-cache\_logs\2022-06-04T18_34_40_792Z-debug-0.log
Full log output: PasteBin
package.json
{
"name": "MyElectronApp",
"productName": "MyElectronApp",
"desktopName": "MyElectronApp",
"version": "1.0.0",
"description": "Foobar",
"main": "app.js",
"repository": "https://github.com/",
"keywords": [],
"author": "cognophile",
"license": "GNU General Public License v3.0",
"files": [
"app.js",
"assets/styles.css",
"resources/icon.png",
"resources/icon.ico",
"resources/icon.icns"
],
"scripts": {
"start": "npx electron .",
"build": "npm run build:macos && npm run build:linux && npm run build:windows",
"build:macos": "npx electron-packager . --overwrite --asar --out=dist --ignore='^media$' --prune --platform=darwin --arch=x64 --icon=resources/icon.icns --app-bundle-id=com.cognophile.myelectronapp --app-version=$npm_package_version && cd dist/MyElectronApp-darwin-x64 && zip -ryXq9 ../MyElectronApp-macos-${npm_package_version}.zip MyElectronApp.app",
"build:linux": "npx electron-packager . --overwrite --out=dist --ignore='^media$' --prune --platform=linux --arch=x64 --icon=resources/icon.png --app-bundle-id=com.cognophile.myelectronapp --app-version=$npm_package_version && cd dist/MyElectronApp-linux-x64/ && zip -ryq9 ../MyElectronApp-linux-${npm_package_version}.zip *",
"build:windows": "npx electron-packager . --overwrite --asar --out=dist --ignore='^media$' --prune --platform=win32 --arch=ia32 --icon=resources/icon.ico --version-string.ProductName=$npm_package_productName --app-version=$npm_package_version && cd dist/MyElectronApp-win32-ia32 && zip -ryq9 ../MyElectronApp-windows-${npm_package_version}.zip *"
},
"devDependencies": {
"electron": "^13.6.6",
"electron-builder": "^22.4.1",
"electron-packager": "^14.2.1"
},
"dependencies": {
"about-window": "^1.15.2"
}
}
Trying to run the scripts results in the same error, with differing details. For example, trying to execute the npm start script. The same is true for npm run build:windows, but the unfetchable package URL in the error is https://registry.npmjs.org/electron-packager
❯ npm start
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
> MyElectronApp#1.0.0 start
> npx electron .
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code EBUSY
npm ERR! syscall rename
npm ERR! path C:\Users\<username>\AppData\Local\npm-cache\_cacache\tmp\01286790
npm ERR! dest C:\Users\<username>\AppData\Local\npm-cache\_cacache\content-v2\sha512\1b\71\c52f6c1e74e5c3c22e0f872bae840fa8e460c356b5c1f807c437a1f8cad2b7bfeb884bb387cbd8012a08d5deaa4b1395f5d4d1cfbc00cfd1b4f5c5e201e3
npm ERR! errno EBUSY
npm ERR! Invalid response body while trying to fetch https://registry.npmjs.org/electron: EBUSY: resource busy or locked, rename 'C:\Users\<username>\AppData\Local\npm-cache\_cacache\tmp\01286790' -> 'C:\Users\<username>\AppData\Local\npm-cache\_cacache\content-v2\sha512\1b\71\c52f6c1e74e5c3c22e0f872bae840fa8e460c356b5c1f807c437a1f8cad2b7bfeb884bb387cbd8012a08d5deaa4b1395f5d4d1cfbc00cfd1b4f5c5e201e3'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\<username>\AppData\Local\npm-cache\_logs\2022-06-04T19_08_01_775Z-debug-0.log
Attempted solutions
I've tried a number of suggestions from a variety of sources, including (npm ERR! code ENOENT npm ERR! syscall rename [StackOverflow]):
Clearing the cache with npm cache clean --force then reinstalling (npm install)
Verifying the cache with npm cache verify then reinstralling (npm install)
Removing node_modules and package-lock.json, clearing the cache, and reinstalling
Removing read-only checkbox from project folder and cache folder (right-click > properties) which seems to immediately get reset
I've tried these in dedicated PowerShell terminals (non-admin and admin), and the integrated terminal in Visual Studio Code, all having the same result. I've also tried:
Repairing the nodejs installation via the installer
Uninstalling nodejs and removing node/npm related files and directories, restarting the PC, and reinstalling nodejs and attempting npm install in a fresh PowerShell terminal
Rebooting to ensure no other processes are using these directories (such as vscode or another terminal instance)
Closing anti-virus program (not attempted a full uninstall) and trying the above solutions
I suspect this relates to permissions on the cache directories, judging by the error message, but since it is npm which creates those directories after the npm cache clean, I'm not sure I understand what more is needed, and am naturally hesitant to change directory permissions (e.g. NodeJS change file and folder permissions [StackOverflow]) until having received advice.
Thanks in advance!

npm link package name must have a name field to be linked

Hi I am trying to create a docker image.
Below is a part of my docker file which is causing problem.I think the problem is due to nodejs package.
The current softlink is:
ls -la "/usr/bin/npm"
lrwxrwxrwx 1 root root 25 Mar 2 01:50 /usr/bin/npm -> /usr/lib/node_modules/npm
Installation is does by a nonroot user
Docker File
#Install node js and npm
RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
RUN apt-get -y install nodejs
RUN npm install -g bower gulp
RUN npm install -g node-gyp#latest --save
RUN npm init -y
RUN npm install -g n
RUN npm install zmq --save
RUN ldconfig
RUN npm config set prefix ~/npm
#RUN npm install -g stf t
#RUN npm install
#RUN rm -rf /usr/bin/npm
#RUN ln -s /usr/lib/node_modules/npm/ /usr/bin/npm
RUN npm link
Below is the docker build output:
Step 35/42 : RUN npm init -y
---> Running in abf773c34e35
Wrote to /package.json:
{
"name": "",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
Step 38/42 : RUN ldconfig
---> Running in 1562e282d324
Removing intermediate container 1562e282d324
---> bdf746069a90
Step 39/42 : RUN npm config set prefix ~/npm
---> Running in 400512f792d0
Removing intermediate container 400512f792d0
---> 0f3eeb03910c
Step 40/42 : RUN npm link
---> Running in 40ae29419291
npm ERR! Linux 4.4.0-98-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "link"
npm ERR! node v6.13.0
npm ERR! npm v3.10.10
npm ERR! Package must have a name field to be linked
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /npm-debug.log
The command '/bin/sh -c npm link' returned a non-zero code: 1
Any help would be appreciated.Thanks
The problem is that the generated package.json does not have the name property set "name": "",.
As documented in npm-link:
Note that package-name is taken from package.json, not from directory name
The reason why name is empty in package.json is that you are running npm init in the root / of the container.
You have to create a directory and run npm init in there.
...
WORKDIR /app
RUN npm init -y
...

nodemon not found in npm

I have a problem: nodemon does not run off the npm script (e.g. npm start),
but if nodemon is called on the command line outside the npm script, nodemon runs as normal.
$ nodemon server.js
14 Feb 22:59:51 - [nodemon] v1.3.7
14 Feb 22:59:51 - [nodemon] to restart at any time, enter `rs`
14 Feb 22:59:51 - [nodemon] watching: *.*
14 Feb 22:59:51 - [nodemon] starting `node server.js`
How it is called in npm script:
package.json
{
...
"scripts": {
"start": "nodemon server.js"
}
}
When npm start script is run:
$ npm start
> aaa#0.0.1 start /home/akul/Documents/aaa
> nodemon server.js
sh: 1: nodemon: not found
npm ERR! Linux 3.13.0-45-generic
npm ERR! argv "node" "/home/akul/npm-global/bin/npm" "start"
npm ERR! node v0.12.0
npm ERR! npm v2.5.0
npm ERR! code ELIFECYCLE
npm ERR! aaa#0.0.1 start: `nodemon server.js`
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the aaa#0.0.1 start script 'nodemon server.js'.
npm ERR! This is most likely a problem with the aaa package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! nodemon server.js
npm ERR! You can get their info via:
npm ERR! npm owner ls aaa
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/akul/Documents/aaa/npm-debug.log
I've been looking for a solution, but have not found one.
You can resolve this problem by adding nodemon to your package.json:
npm install nodemon --save-dev
The problem happens when nodemon does not exist in /node_modules/.bin.
Added --save-dev since it's required during development only.
Try to check installed global packages npm list -g --depth=0. If you will not find nodemon, - install it with flag -g or --save-dev. Don't install nodemon with flag --save, because nodemon uses only for development.
under your current project directory, run
npm install nodemon --save //save in package.json so that the following code cam find your nodemon
then under "scripts" in your package.json file, add "start": "nodemon app.js" (or whatever your entry point is) so it looks like this:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js"
}
and then run
npm start
That avoids complicate PATH settings and it works on my mac
hope can help you ;)
Install nodemon globally using following command. It works on my computer, and I'm sure it will work on your system also.
npm install nodemon -g --save
Sometimes you should have the permission to install it globally. It can be easily done by using following command.
In LINUX UBUNTU:
sudo npm install nodemon -g --save
In Fedora:
a) su
b)npm install nodemon -g --save
Try to install nodemon globally.
sudo npm install -g nodemon
Here's how I fixed it :
When I installed nodemon using : npm install nodemon -g --save , my path for the global npm packages was not present in the PATH variable .
If you just add it to the $PATH variable it will get fixed.
Edit the ~/.bashrc file in your home folder and add this line :-
export PATH=$PATH:~/npm
Here "npm" is the path to my global npm packages . Replace it with the global path in your system
heroku runs in a production environment by default so it does not install the dev dependencies.
if you don't want to reinstall nodemon as a dependency which I think shouldn't because its right place is in devDependencies not in dependencies.
instead, you can create two npm script to avoid this error by running nodemon only in your localhost like that:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js",
"start:dev": "nodemon --watch"
},
and when you want to run the project locally just run in your terminal npm run start:dev and it will load app.js by nodemon.
while in heroku npm start runs by default and load app.js from a normal node command and you get rid of that error.
You have to simply installed it globally.
npm install -g nodemon
This solution had worked for me:
I assume that you have installed nodemon globally. If it's done follow this steps:
open your .bash_profile file:
nano .bash_profile
past this to add a new alias in your bash profile:
alias nodemon='~/.npm-global/lib/node_modules/nodemon/bin/nodemon.js'
Now you can use nodemon command anywhere.
sudo npm install nodemon -g --save
Finally this worked for me. I hope this must work for others too
My nodemon vanished after installing babel (why?).
Tried a lot of stuff.
Here is how I solved it:
sudo npm i -g nodemon
Just reinstall it with sudo. Yeah.
For Visual Studio Code editor with Windows Sub-system for Linux, i.e, WSL mode:
sudo npm install nodemon -g
for global use of nodemon.
I had the same problem and was able to solve it. This was me error:
npm install -g nodemon
npm WARN checkPermissions Missing write access to /usr/local/lib
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#~2.3.2 (node_modules/nodemon/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib' }
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/rayani00/.npm/_logs/2022-01-03T17_50_15_842Z-debug.log
(base) rayani00#rayani00:~/Bureau/my-express-server$ npm cache clear --force
npm WARN using --force I sure hope you know what you are doing.
To solve it i just aded a sudo for the nodemon installation :
sudo npm install -g nodemon
nodemon server.js
That worked for me!
NPM is used to manage packages and download them. However, NPX must be used as the tool to execute Node Packages
Try using NPX nodemon ...
Hope this helps!
This worked for me ...
Install nodemon as a local dev dependency
npm install --save-dev nodemon
Add script to your application package.json to start the application.
"scripts": {
"start": "nodemon app.js"
},
Start nodemon with npm start
$ npm start
> node-rest-demo#1.0.0 start node-rest-demo
> nodemon app.js
[nodemon] 1.19.4 [nodemon] to restart at any time, enter `rs` [nodemon] watching dir(s): *.* [nodemon] watching extensions: js,mjs,json [nodemon] starting `node app.js` Starting server ...
I faced a similar issue, but then checked .npmrc file and there was incorrect password in that that caused the connection failure and there fore yarn --verbose returned Bad request error. After correcting the password, the packages were added successfully.
I found a very easy solution.
Simply delete the npm and npm cache folder from your pc.
Reinstall it again, but the mistake that many of us make is not installing npm globally.So:
npm i -g npm
And then, install nodemon globally:
npm i -g nodemon
Now,nodemon works globally, even without using the command:
npx nodemon <yourfilename>.js
npx nodemon (app.js) worked for me and nodemon (app.js) did not.
I updated node.js to the latest version and now both are working.
I had this problem and even after I have used the command npm install nodemon --save in my application, I still had problem with nodemon.
I just resolved after I installed nodemon globally, using the command:npm install nodemon -g
Had the same problem otherwise was just working fine a day ago.
Very simple fix
first check if nodemon exists on your system globally or not
To check
npm list -g --depth=0
If you don't see then install
it npm install -g nodemon (g stands for globally)
If you see it still doesn't work then you need to configure environment variable
I use Windows OS. On Windows navigate to
Control panel>System>Advanced System Settings>Environment Variables>double-click on PATH
Now check if you have this PATH C:\Users\yourUsername\AppData\Roaming\npm
If not, you will see some existing paths, just append to it separating with semicolon. That's it! Worked for me.
For me node was installed in C:..\Roaming\npm and for you if the PATH is different, you will put in whatever applcable.
First install nodemon to your working folder by
npm install nodemon
Add the path of nodemon to the path variable of Environment Variable of System environment.
In my case the path of nodemon was.
C:\Users\Dell\Desktop\Internship Project\schema\node_modules\.bin
It worked for me.
You can always reinstall Node.js. When I had this problem, I couldn't fix it, but all I did was update the current version of Node. You can update it with this link: https://nodejs.org/en/download/
I wanted to add how I fixed this issue, as I had to do a bit of mix and match from a few different solutions. For reference this is for a Windows 10 PC, nodemon had worked perfectly for months and then suddenly the command was not found unless run locally with npx.
Here were my steps -
Check to see if it is installed globally by running npm list -g
--depth=0, in my case it was installed, so to start fresh...
I ran npm uninstall -g nodemon
Next, I reinstalled using npm install -g --force nodemon --save-dev (it might be recommended to try running npm install -g nodemon --save-dev first, go through the rest of the steps, and if it doesn't work go through steps 2 & 3 again using --force).
Then I checked where my npm folder was located with the command npm config get prefix, which in my case was located at C:\Users\username\AppData\Roaming\npm
I modified my PATH variable to add both that file path and a second entry with \bin appended to it (I am not sure which one is actually needed as some people have needed just the root npm folder and others have needed bin, it was easy enough to simply add both)
Finally, I followed similar directions to what Natesh recommended on this entry, however, with Windows, the .bashrc file doesn't automatically exist, so you need to create one in your ~ directory. I also needed to slightly alter how the export was written to be export PATH=%PATH%;C:\Users\username\AppData\Roaming\npm; (Obviously replace "username" with whatever your username is, or whatever the file path was that was retrieved in step 4)
I hope this helps anyone who has been struggling with this issue for as long as I have!
--save, -g and changing package.json scripts did not work for me. Here's what did: running npm start (or using npx nodemon) within the command line. I use visual studio code terminal.
When it is successful you will see this message:
[nodemon] 1.18.9
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting node app.js
Good luck!
In my case nodemon needed to be installed globally:
npm i nodemon -g --save
I tried to list global packages using npm list -g --depth=0, but couldn't find nodemon.
Hence, tried installing it using global flag.
sudo npm install nodemon -g
This worked fine for me.
Instructions for Windows,
Open Command Prompt.
type npm i -g nodemon --save
"--save" is to save the addition of this node package in your project's package.json file
I my case:
npm install nodemon
With out any flags etc.
for linux try
sudo npm install -g nodemon
for windows
open powershell or cmd as administration
npm install -g nodemon
I got this issue while deploying on Heroku.
The problem is on Heroku the don't include the devDependencies on its own.
To fix this issue, simply run the command in the terminal:
heroku config:set NPM_CONFIG_PRODUCTION=false
Make sure to include nodemon in your devDependencies
"devDependencies": {
"nodemon": "^2.0.6"
}
Incase your error is not in Heroku
I would suggest uninstalling nodemon and then reinstalling it
https://www.npmjs.com/package/nodemon
Or try changing the script
"scripts": {
"start": "nodemon fileName.js",
"start:dev": "nodemon fileName.js"
}
Hope it would help :)

Installing bootstrap with npm is failing

I am attempting to install bootstrap (LESS) with npm on Debian but it keeps failing.
This is exactly what i am doing:
git clone https://github.com/twbs/bootstrap.git
npm install
The error i get is simply Killed.
Running the npm install in verbose i do not get any error:
npm verb readDependencies using package.json deps
npm http GET https://registry.npmjs.org/postcss/-/postcss-2.2.5.tgz
npm info retry fetch attempt 1 at 01:00:50
npm verb fetch to= /tmp/npm-3690-Rr0nZSRK/registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000010.tgz
npm info postinstall ansi-regex#0.2.1
Killed
npm install
simply installs the upstream dependencies based on what is listed in the package.json in your current directory
Try this
git clone https://github.com/twbs/bootstrap.git
cd bootstrap
npm install # installs dependencies
npm install -g bootstrap # does actual install of bootstrap into module dir
note the -g in the install command puts bootstrap into your global npm module directory
as defined by environment variable $NODE_PATH
You can also low down memory consumption by "npm config set jobs 1", did work for me ;) link: https://community.c9.io/t/npm-install-is-killed/847

Npm install failed with "cannot run in wd"

I am trying to get my node environment set up on a new Ubuntu 12.04 instance, with Node 0.8.14 already installed, but I ran into problems when I try to run npm install.
So when I try npm install, it says that I need to run it as root or adminisrator:
Error: EACCES, mkdir '/usr/local/lib/node_modules/coffee-script'
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/coffee-script']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/coffee-script',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/coffee-script',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ 'DirWriter._create (/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23)',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR! 'Object.oncomplete (fs.js:297:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
But when try to run it as sudo, it says the following:
npm WARN cannot run in wd PackNodeDev#0.0.1-166 npm install -g coffee-script node-gyp (wd=/home/ubuntu/PackNode)
In my package.json, it contains the following scripts:
"scripts": {
"preinstall": "npm install -g coffee-script node-gyp",
"start": "node server.js",
"test": "mocha --require should --compilers coffee:coffee-script --colors"
},
The rest of devdependencies are valid since I have been installing it all right on my own machine (Mac)
Does anyone have a clue why this is happening?
The documentation says (also here):
If npm was invoked with root privileges, then it will change the uid to the user account or uid specified by the user config, which defaults to nobody. Set the unsafe-perm flag to run scripts with root privileges.
Your options are:
Run npm install with the --unsafe-perm flag:
[sudo] npm install --unsafe-perm
Add the unsafe-perm flag to your package.json:
"config": {
"unsafe-perm":true
}
Don't use the preinstall script to install global modules, install them separately and then run the regular npm install without root privileges:
sudo npm install -g coffee-script node-gyp
npm install
Related:
package.json for global module installation
The only thing that worked for me was adding a .npmrc file containing:
unsafe-perm = true
Adding the same config to package.json didn't have any effect.
I have experienced the same problem when trying to publish my nodejs app in a private server running CentOs using root user. The same error is fired by "postinstall": "./node_modules/bower/bin/bower install" in my package.json file so the only solution that was working for me is to use both options to avoid the error:
1: use --allow-root option for bower install command
"postinstall": "./node_modules/bower/bin/bower --allow-root install"
2: use --unsafe-perm option for npm install command
npm install --unsafe-perm
OP here, I have learned a lot more about node since I first asked this question. Though Dmitry's answer was very helpful, what ultimately did it for me is to install node with the correct permissions.
I highly recommend not installing node using any package managers, but rather to compile it yourself so that it resides in a local directory with normal permissions.
This article provides a very clear step-by-step instruction of how to do so:
https://www.digitalocean.com/community/tutorials/how-to-install-an-upstream-version-of-node-js-on-ubuntu-12-04
!~~ For Docker ~~!
#Alexander Mills answer - just made it easier to find:
RUN npm set unsafe-perm true
I fixed this by changing the ownership of /usr/local and ~/Users/user-name like so:
sudo chown -R my_name /usr/local
This allowed me to do everything without sudo

Resources