1. npm安装install报错4058
npm WARN checkPermissions Missing write access to G:\work-else\danta-elem\node_modules\debug\node_modules\ms
npm WARN checkPermissions Missing write access to G:\work-else\danta-elem\node_modules\debug\node_modules
npm WARN The package vue is included as both a dev and production dependency.

npm ERR! path G:\work-else\danta-elem\node_modules\debug\node_modules\ms
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access 'G:\work-else\danta-elem\node_modules\debug\node_modules\ms'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     E:\Program Files\nodejs\node_cache\_logs\2018-04-09T14_22_05_244Z-debug.log
复制代码

npm errno -4058

问题出现环境:

win10系统
gitbash下安装npm install
npm已经设置了淘宝源

解决:npm安装没有权限。改用命令行管理员身份运行。

  1. npm run dev 打开监听页面后出现cannot get/

确定webpack 的config index.js文件没有出问题

dev: {
   env: require('./dev.env'),
   port: 8888,
   autoOpenBrowser: true,
   assetsSubDirectory: 'static',
   assetsPublicPath: '/',
   proxyTable: {},
复制代码

然后检查报错: 这是gitbash运行npm run dev 的报错:

modules\debug\node_modules\ms
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access 'G:\work-else\danta-elem\node_modules\debug\node_modules\ms'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     E:\Program Files\nodejs\node_cache\_logs\2018-04-09T14_22_05_244Z-debug.log
复制代码

这是webstorm下的terminal运行npm run dev 后的报错

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.8.3 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.8.3 postinstall 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!     E:\Program Files\nodejs\node_cache\_logs\2018-04-09T15_08_59_073Z-debug.log
复制代码

使用命令行管理员运行后监听页面显示正常。 所以问题应该是权限问题。 打开webstorm的错误日志,发现报错是node的索引源有问题。点击报错的红字进行node.js&npm设置。如图所示: nodejs is not enabled。点击enable按钮。

然后变成这样。
此时在terminal里使用命令,就正常运行了。

转载于:https://juejin.im/post/5acb79bf6fb9a028b86e5327

Logo

前往低代码交流专区

更多推荐