Mac webpack 安装报错 permission den
2019-07-10 本文已影响0人
呦释原点
webpack 安装报错
- node.js 安装 官网下载安装即可 https://nodejs.org/en/
- webpack 安装
sudo npm install webpack -g
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for fsevents@1.2.9 and node@11.14.0 (node-v67 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/webpack/node_modules/fsevents/lib'
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/webpack/node_modules/fsevents/build'
gyp ERR! System Darwin 18.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/webpack/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/webpack/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v67"
gyp ERR! cwd /usr/local/lib/node_modules/webpack/node_modules/fsevents
gyp ERR! node -v v11.14.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
解决办法
sudo npm install webpack -g
或
sudo npm install webpack -g --unsafe-perm=true --allow-root
(我用的此方法)
或
sudo npm install webpack -g --unsafe-perm=true
-
这时终端输入
webpack -v
可能会提示 webpack-cli没有安装,如下图
webpack-cli
如果直接使用yes 或npm install -D 或 sudo npm install -D 都有可能报错
此时试试sudo npm install webpack-cli -g
再次检查就可以webpack -v
-
vue -cli 安装
sudo npm install vue-cli -g
项目启动时报错
webpack-dev-server --inline --progress --config build/webpack.dev.conf.js
翻译过来就是: 'webpack-dev-server' 不是内部或外部命令,也不是可运行的程序
很可能是项目 install
时不完全造成的, 可以使用cnpm install
境内安装
项目初始化时最后会让你选择是否install和install途径, 最好是选择稍后手动安装cnpm install
sh: webpack-dev-server: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
刚拿到项目时, npm start 或npm run dev 包这个错 先执行cnpm install 安装依赖文件
- cnpm: command not found 切换到淘宝镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org
项目初始化
-
在你要创建项目的文件夹下 vue init webpack '文件名', 然后依次录入 项目名、项目描述
录入项目名










都是图、都是图 😂😂😂😂😂