刚开始使用vscode打开一个已写好的vue。
1.根据网上教程,下载并配置好nodejs
2.利用vscode打开已有vue文件
3.使用命令行,输入

npm install

4.然后就报出如下错误

localhost:react-first changwei$ npm install --save react-router
npm WARN deprecated core-js@1.2.7: core-js@<2.6.5 is no longer maintained. Please, upgrade to core-js@3 or at least to actual version of core-js@2.

> fsevents@1.2.4 install /Users/changwei/project/react-first/node_modules/fsevents
> node install

node-pre-gyp WARN Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.4/fse-v1.2.4-node-v67-darwin-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for fsevents@1.2.4 and node@11.12.0 (node-v67 ABI, unknown) (falling back to source compile with node-gyp) 
gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /Users/changwei/anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack 
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:297:12)
gyp ERR! stack     at ChildProcess.emit (events.js:197:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:988:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:404:11)
gyp ERR! stack     at Socket.emit (events.js:197:13)
gyp ERR! stack     at Pipe._handle.close (net.js:611:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/Cellar/node/11.12.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/changwei/project/react-first/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node" "--module_name=fse" "--module_path=/Users/changwei/project/react-first/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64" "--napi_version=4" "--node_abi_napi=napi"
gyp ERR! cwd /Users/changwei/project/react-first/node_modules/fsevents
gyp ERR! node -v v11.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/11.12.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/changwei/project/react-first/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node --module_name=fse --module_path=/Users/changwei/project/react-first/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64 --napi_version=4 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/changwei/project/react-first/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:197:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:988:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
node-pre-gyp ERR! System Darwin 17.7.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/11.12.0/bin/node" "/Users/changwei/project/react-first/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/changwei/project/react-first/node_modules/fsevents
node-pre-gyp ERR! node -v v11.12.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.0
node-pre-gyp ERR! not ok 

感觉像是python找不到,或者py的版本不对
5.解决以上报错
卸载并重新安装、配置 nodejs
********实测有效!
备注:npm install 没问题后,再 npm run dev 还是报错,运行不起来,看一下错误。一般应该是 Cannot find module 'node-sass‘,然后按照网上教程再操作一下,就可以了。
友情链接('node-sass‘):https://blog.csdn.net/com_it/article/details/95043471

Logo

前往低代码交流专区

更多推荐