node.js - 在恢复 package.json 包时出现 VS2015 中不允许的方法错误?

标签 node.js angular typescript npm visual-studio-2015

当我在 VS2015 中恢复 package.json 时出现Method Not Allowed 错误。

enter image description here enter image description here

这是我得到的日志:

npm ERR! Error: Method Not Allowed
npm ERR!     at errorResponse (C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\npm\node_modules\npm\lib\cache.js:753:14)
npm ERR!     at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\npm\node_modules\npm\lib\cache.js:773:12
npm ERR!     at saved (C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\npm\node_modules\npm-registry-client\lib\get.js:148:7)
npm ERR!     at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\npm\node_modules\graceful-fs\polyfills.js:133:7
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\External\\npm\\node" "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\External\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\...\Angular2\Angular2
npm ERR! node -v v0.10.31
npm ERR! npm -v 1.4.9
npm ERR! code E405

最佳答案

我觉得您正在尝试从 VS2015 开始执行此操作。 Visual Studio 使用 NPM 的预打包版本。通过查看您的日志,我们还可以看出它使用的是 npm 1.4.9,它非常旧。

您可以导航到 C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\ 并执行 npm install npm -g 来更新它。

您可能需要告诉 VS 使用较新版本的 Node 。它似乎使用的是 Node 0.10.31,它已经很老了。 This guide应该对你有帮助。

编辑

或者,您可以指定希望 Visual Studio 使用的 NPM 位置。您可以在 Tools -> Options -> Projects and Solutions -> External Web Tools 下更改当前路径。在 .\node_modules\.bin 上方增加 $(PATH) 也应该可以解决问题。

how to change the location of NPM Visual Studio 2015

Source (for updating npm)

Source (for changing location)

关于node.js - 在恢复 package.json 包时出现 VS2015 中不允许的方法错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53735592/

相关文章:

angular - 如何在 angular 2 中动态设置 index.html 中的 Google map 键?

Angular - HostListener 指令和传递值

typescript - 禁用允许将只读类型分配给非只读类型

reactjs - 如何修复 "React Hook useEffect has a missing dependency. Either include it or remove the dependency array"问题?

node.js - 静态 javascript 未在 jade 中呈现(使用 express/node.js)

javascript - Sequelize 类型错误 : Cannot read property 'max' of undefined

javascript - 无法将虚拟键盘 jQuery 插件与 Angular 4 +Webpack 一起使用

javascript - 为什么 req.somevariable 和 res.locals 不能与 jwt 回调一起使用?

node.js - Mongod 未运行.. E 网络 [initandlisten] Listen() : bind() failed errno:98 Address already in use for socket: 0. 0.0.0:27017

angular - Jasmine 测试属性可观察订阅