我不能在NodeJS中使用命令提示符使用npm install。我在运行npm install时得到这些错误:

module.js:339
    throw err;
    ^
Error: Cannot find module 'semver'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (C:\Users\admin\AppData\Roaming\npm\node_modules\npm\l
ib\config\defaults.js:6:14)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)

当前回答

我得到一个错误说权限被拒绝后运行任何'ng'命令(ng——版本)。我谷歌了一下,尝试清除npm缓存npm缓存验证,卸载我的全局angular cli (npm uninstall -g @angular/cli),重新安装angular/cli (npm install -g @angular/cli)等。但它会给出一个错误,说它已经安装。但是这里的node_modules文件夹不会有任何angular文件夹。重新安装节点,然后重新启动我的电脑。

答案:最后我发现ng。CMD和ng。c:\ users \ jag古德温\ appdata \ roaming \npm\ here中的ps1文件仍然存在(在npm文件夹中)。尽管我做了npm uninstall -g @angular/cli。这些文件导致ng (angular/cli)认为它仍然被安装。我删除了这些文件,然后npm install -g @angular/cli@8.3.29(我需要的版本),然后我删除了我的项目node_modules,然后运行npm install,现在可以使用ng serve运行我的angular项目了。

C: \ Users \ JaGoodwin \ AppData \我办手机漫游npm喝

通过文件夹搜索%APPDATA%在你的windows搜索栏中找到这个。

其他回答

在Ubuntu上,如果你想通过默认的存储库使用apt来管理Node,最好同时安装nodejs和npm。

你正在使用的npm版本很有可能在某个特定的位置期望与你已经安装的Node JS版本不一致。如果只有一个版本的nodejs和一个版本的npm,并且它们都是使用默认存储库安装的,这应该可以完美地工作。

下面是我的最佳指导,让Node和npm使用Ubuntu的主要存储库工作:

sudo apt-get purge nodejs --auto-remove and sudo apt-get purge npm --auto-remove whereis node: remove all the versions of node, one at a time. Repeat until this command returns a blank after node:. sudo apt-get install nodejs node --version: should return ... no such file or directory nodejs --version: should return v1x.x.x. This is the version installed by apt. It will probably be less recent that the latest version available on the Node JS website. sudo apt-get install npm npm --version: it will use the nodejs installed by apt and work correctly.

只需删除/node_modules文件夹,然后重试。,)

你可以使用npm rm来删除它。

你也可以在GitHub上检查这个问题。 更具体地说,unnistal是这样的:

Uninstalling So sad to see you go. sudo npm uninstall npm -g Or, if that fails, sudo make uninstall More Severe Uninstalling Usually, the above instructions are sufficient. That will remove npm, but leave behind anything you've installed. If you would like to remove all the packages that you have installed, then you can use the npm ls command to find them, and then npm rm to remove them. To remove cruft left behind by npm 0.x, you can use the included clean-old.sh script file. You can run it conveniently like this: npm explore npm -g -- sh scripts/clean-old.sh npm uses two configuration files, one for per-user configs, and another for global (every-user) configs. You can view them by doing: npm config get userconfig # defaults to ~/.npmrc npm config get globalconfig # defaults to /usr/local/etc/npmrc Uninstalling npm does not remove configuration files by default. You must remove them yourself manually if you want them gone. Note that this means that future npm installs will not remember the settings that you have chosen.

在Windows上,再次下载Node的MSI并进行“修复”对我有用。

别介意 安装纱。通过npm执行并行安装,从而获得更好的速度和性能

须藤易脱纱 curl - ss https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - 回显"deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list Sudo apt-get update Sudo apt-get install yarn -y

只要确保semver已经安装:npm install -g semver