我想为Jest使用Vue单元测试实用程序。这在Windows上运行得很好,但我在Linux上遇到了一个错误。
我就是这样做的:
vue create my-project
选择Manually select features
Choose vue version
Babel
Typescript
Linter / Formatter
Unit Testing
3.x (preview)
Class-style component syntax
Use Babel alongside ...
Pick a linter
:选择ESLint + standard config
Pick additional lint features
:选择Lint on save
Pick a unit testing solution
:选择jest
Where do you prefer placing config
:选择In package.jsonH246<Save this as a preset for future projects?
的/code>
回答'n‘
然后尝试创建具有以下输出的项目:
Vue CLI v4.5.10
✨ Creating project in /home/admiraal/my-project.
Initializing git repository...
⚙️ Installing CLI plugins. This might take a while...
npm ERR! code 1
npm ERR! path /home/admiraal/my-project/node_modules/deasync
npm ERR! command failed
npm ERR! command sh -c node ./build.js
npm ERR! `linux-x64-node-15` exists; testing
npm ERR! Problem with the binary; manual build incoming
npm ERR! stdout=
npm ERR! err=Error: Command failed: /home/admiraal/.nvm/versions/node/v15.5.1/bin/node quick-test.js
npm ERR! /home/admiraal/my-project/node_modules/bindings/bindings.js:135
npm ERR! throw err;
npm ERR! ^
npm ERR!
npm ERR! Error: Could not locate the bindings file. Tried:
npm ERR! → /home/admiraal/my-project/node_modules/deasync/build/deasync.node
npm ERR! → /home/admiraal/my-project/node_modules/deasync/build/Debug/deasync.node
...
(many "npm ERR!" lines follow)
当我尝试将Jest添加到现有的成功创建的项目时,会出现相同的错误
vue add unit-jest
卸载和重新安装de异步并不能解决这个问题。
发布于 2021-02-09 13:23:01
解决方案是将节点降级为12.0.0版本。
This question/answer帮助我找到了这个解决方案。
若要降级,请执行以下步骤:
nvm install 12.0.0
nvm alias default 12.0.0
nvm use default
https://stackoverflow.com/questions/66099224
复制相似问题