Today I was trying to work on Angular2 (template https://akveo.github.io). As per installation guide, I ran following commands.
I have installed Node.js v6.9.1.
npm install --Worked fine.
npm server --Failed with below error.
E:\........\node_modules\script-ext-html-webpack-plugin\index.js:3
const INLINE = 'inline';
^^^^^
SyntaxError: Use of const in strict mode.
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
After many random searches and failing to resolve it, I decided to think about it with a calm head. To me it looks like it is a problem with ES2015/ES6. Package script-ext-html-webpack-plugin uses const variable which is a ES2016 feature. However system is unable to resolve it.
Also this problem can come with any package like hapi, selinium etc. But everything should have same solution I guess.
I have tried many related commands on the installation guide of the website mentioned above but nothing works and ends with same error. I have also many have faced same issue online but nothing concrete is visible as answer.
Could anyone help me out?
Update
Below approach has also fixed many of my colleague's machine who were facing some random errors with nodejs.
This problem is resolved in at least my machine. I am certainly not a person who understand nodejs completely but got it working after some googling. The solution given below may be common to many other issues I guess.
The system I am working has Windows 10 as Operating System and has 64 bit processor.
Go to control panel and uninstall nodejs (just to make sure you do not have traces of any previous install).
Install latest version of nodejs from their website (I installed v6.9.1 for 64 bit processor).
Go to Environment variables for system (just type environmental variables in start menu if using Windows 10) and edit the Path. Delete ‘C:/Program Files (x86)/nodejs’ (as I had installed 64 bit nodejs). This ensures when using command you do not use any other previously installed nodejs.
Start command prompt in Admin mode and navigate to your project and run npm install.
In case you get any/some error, then run npm info graceful-fs -v or npm info graceful-fs whichever runs in your machine.
Then run npm update -g npm.
Then run npm install again and this time it should work.
Run npm start and everything should work fine.
On running website, sometimes we see any other issue and that can be seen from console logs. But good thing is, console logs also tell you the problem. In most cases its related to 32 bit and 64 bit processor due to our recent changes. In my case, I was facing issue with SASS configuration due to 32/64 bit machine and console log asked me to run npm rebuild node-sass to fix the issue.
Go back to command prompt, hit Ctrl+C to stop npm server. Run node rebuild node-sass. Run npm start again and everything should be working.
Hope it helps.
We are trying to get a simple noflo example running inside a browser as described the noflojs.org/documentation/fbp/ [Language for Flow-Based Programming]
We tried to refer to some examples available on GitHub
github.com/noflo/noflo-browser-app
github.com/noflo/noflo-websocket
github.com/bergie/flowcopter
We tried npm install; grunt build. We get the below error and are not able to proceed beyond this:
Running "noflo_browser:build" (noflo_browser) task install
noflo/noflo#master Warning: dns lookup failed Use --force to
continue.
Any idea what are we missing ?
At the time of the question the build setup for the projects mentioned was still based on Component.js which had become unmaintained.
Nowadays we're using NPM for installing dependencies and WebPack for browser builds.
Suggested fix would be to fetch the latest versions of these repos, do npm install and build again. This will bring the build up to spec.
If you're using the old build setup in your own projects, this PR is a handy example on what to change to go from Component.js to WebPack.
My current npm version is 3.7.3 . Previously, only the required packages were getting installed in my node modules. But right now they have all flattened and have 100 + folders visible when I look into node modules. I prefer the older way where you could go into individual folders and see their dependencies.
here is a similar thread:
Why does npm install many packages into "/node_modules" instead of only one?
I tried running npm uninstall without much success.
Basically, you are out of luck... NPM does not provide any configuration options regarding this. It will nest dependencies if it must in order to resolve version conflicts, but only in this case. Your only option is to downgrade NPM (not recommended). However, if you just need to see the dependencies nested for informational reasons, you can use npm ls. It will draw you a graph.
See this relevant NPM issue for more discussion: https://github.com/npm/npm/issues/9809
Now that node js' LTS doesn't include an NPMv2 I found myself stuck with this issue again.
For those of you also caught out, the link that #KevinBurdett mentioned, also has some answers.
You can force downgrade npm using npm itself (using sudo or equivalent for this). From https://github.com/npm/npm/issues/9809#issuecomment-179702479:
as root I simply do npm install -g 'npm#<3' on my system every time I
a new version of Node comes out; your mileage might vary, but it's
fairly trivial to "downgrade" :-)
Another alternative is to use the Node Version Manager (NVM): https://github.com/creationix/nvm. Your mileage may vary depending upon personal config/preferences/platform.
That said, npm 3 and the issue of flat dependency trees will be with us from hereafter... It's probably high time to start accepting that change.
My personal grudge with this is that it makes the node_modules folder incredibly difficult to work with in an IDE, especially when you need to look at the implementation of your immediate dependent modules, without first wading through 100's of sub-sub modules that are irrelevant to me. It seems that I'm not alone in this matter when you read the comments in the issue. It only leads me to question the viability of npm itself when such changes are made without a proper migration from old to new systems. For me, npm2 will always be king.
I've looked through the different articles here, but I'm not finding out the answer I need, or don't understand necessarily what has been explained in other posts.
I downloaded node.js got my github up and have cloned the phonecat site, that part works fine. I can even check npm/node versions through cmd, but whenever I install using either "npm install" or "npm install -g" "Couldn't read depndencies" couldn't find package.json" has a long list of errors:
http://tinypic.com/1r54rjf4
I have tried caching, updating, restarting, uninstalling, reinstalling, giving permissions to fully allow windows system32 for commands. I have been reading for a few hours, and I am just at a complete loss here. Any help would be greatly appreciated!
When you don't specify a module to download, npm will look for a package.json. It's not finding one, which is why you're seeing all kinds of errors.
Is there a project you're working on? If you want to start a new one you can run npm init. If there's an existing one that has a package.json, you can navigate to that directory in your terminal and then npm install should work.
I didn't. I'm still wrestling with it. I'm not sure what to do about it either. I had one of my friends come over that's familiar with node and he couldn't figure it out. It must be a permissions issue somewhere on the computer. I can't figure out what else it could be.
For me is npm install extremely slow. I'm using Windows 8.1 with the latest npm version. My connection speed is around 100Mbit/s.
The project I'm trying to install has around 20 packages/dependencies and it takes around 30 Minutes to install all dependencies ...
Does anyone have a clue?
I ran into the same problem, using --verbose as peterh mentioned showed me the source of the problem: I am behind a proxy, which uses its own certificates for https-connections.
According to user "Mletter1" on https://github.com/npm/npm/issues/8872 the issue is quite easily solved by using http:
npm config set registry http://registry.npmjs.org/ --global
And voilà, it's fast again. Of course you should only do this, if you're ok with cleartext npm infos over the net ;-)
Warning regarding security: this is an insecure approach if you don't use any other means of antivirus protection.
From eternity → to 5 seconds builds:
search for Windows Defender settings
→ Virus & threat protection
→ Virus & threat protection Settings
→ Exclusions
here add this two paths to your list of excluded realtime protection folders:
C:\Program Files\nodejs
C:\Users\<your username>\AppData\Roaming\npm
PS: replace the <your username> with your respective User folder name; or use alias to the AppData folder like: %AppData%\npm
If you're wondering why you can't find the AppData folder in Explorer, make sure to check "View" options for "Show hidden folders".
I know its just a workaround, but try using the build-in "Windows PowerShell"
I've been facing the same issue for a while. I was trying out the following
npm i typescript live-server --save-dev
The install would get stuck at it forever. However adding the -verbose flag worked just fine.
It seems like npm do not deal well with internet connections and can sometimes end in such situation.
1) I'll advice you to check if your firewall or antivirus is not performing any scan or filtering which may slow down npm install.
2) You may also use caching from npm like below.
npm install package-name --cache "c:\path\to\use\as\dependencies\cache"
this will allow npm download and cache dependencies in the directory you specified.
3) another solution for caching npm packages dependencies is npm lazy, you may find more information about this at npm Lazy website
Note: the caching process may or may not improve the download speed but it will probably save downloads time when installing or updating your npm packages.
For me it appeared to be a problem with IPv6.
Disabling IPv6 helped immensely for me.
With IPv6 turned on "update-package newtonsoft.json" took 1:45 to time out with the error "update-package : A task was canceled."
With IPv6 disabled "update-package newtonsoft.json" completed in 10 seconds
Turning off Windows Firewall and Windows Defender Real-time protection did it for me in Windows 10.
Fully turning off virus and firewall protection isn't the safest option. While it makes things faster, it leaves you more vulnerable.
In my case, I only excluded the node.exe process in virus & threat protection.
In your start menu, type "windows security" and open the app.
Click on "Virus & threat protection"
Virus & threat protection settings => Manage settings
Exclusions => Add or remove exclusions
Add an exclusion => process => type node.exe => click Add
just a simple create-react-app went down from 2m40s to 1m10s
npm commands are also executed by node.exe, so the same improvements are noticed there.
I faced the same issue while creating project while using angular cli "ng new PROJECT_NAME" this command triggers "npm -install" after creation of project, which took too long to install, and got stuck at "Installing packages for tooling via npm" . Follow these which worked for me
1) Check your npm version "npm --version" (must be higher than 2.1.8)Update your npm package by "npm -g install --save latest-version"
2) Remove the progress bar which consumes more time "npm set progress=false"
check this issues if still doesn't fix your problem
https://github.com/nodejs/node/issues/4150
https://github.com/npm/npm/issues/11283
Hopefully this sorts the problem Cheers!
In my case it was due to over 200 vulnerabilities. When I ran
npm audit fix
that solved only just a few of them. Eventually, I had to run
npm audit fix --force
and it got way better than before.
I tried all the config's (proxy, registry, etc) nothing worked for me, so did a complete uninstall and install node & npm. Which helped to solve the issue.
Turning off the Windows Defender Firewall helped for me.
Because it just doesnt feel right I first added the WIFI to a Private Network (via WIFI settings) and only turned off the Windows Defender for a Private Network instead of all public Networks.
The next step should be: what network traffic causes this and how to add this to the Windows Defender exception rule :)
Make sure you really are using a recent version of npm. In my case C:\Program Files\nodejs\npm.cmd had been using an old npm-cli.js below the default prefix folder %appdata%\npm rather than a newer npm-cli.js below C:\Program Files\nodejs.
Setting the environment variable npm_config_prefix to C:\Program Files\nodejs solved that. (Before finding that solution, I tried using the --prefix argument and found out the hard way doing so "forces non-global commands to run in the specified folder".)
I found a huge performance increase going from 3.10.9 to 6.13.4-- enough to make npm install times acceptable despite interference from antivirus.
I just went through a rabbit hole trying to identify the issue. If npm install keeps getting bottlenecked you should heavily consider modifying the properties of your virtual ethernet and disable all of the offload items.
I had 0 proxies or caching issues with npm.
See here for the tutorial on how to get to the menu and disable your offload settings. Make sure you do this for both your your ethernet and VEthernet and you should immediately notice a difference. I went from a 10 minute hanging resolution that sometimes just stopped down to 10 seconds installs.
https://www.dincloud.com/blog/tuning-windows-get-15x-speeds-on-large-file-copies-today
in addition to all other great comments, I'd also suggest switching to yarn (https://marketplace.visualstudio.com/items?itemName=geeklearningio.gl-vsts-tasks-yarn).
using devops (selfhosted agent v.2.192.0), with node (v.14.17.6), we were able to trim total build (install + build) from ~10min to ~6-7 min.
This is highly situational but we have a local registry (npm config get registry) that was not available (VPN:d) in when I was running the npm install ... and this obviously made it very slow but it still succeeded because everything was still available through cache.