问题描述
我正在尝试运行 React-app 空白项目,但出现此错误:
~/dev/js?npx create-react-app my-app
npx: installed 67 in 3.618s
Creating a new React app in /home/erik/dev/js/my-app.
Installing packages. This might take a couple of minutes.
Installing react,react-dom,and react-scripts with cra-template...
yarn add v1.22.10
[...]
└─ web-vitals@1.1.2
Done in 6.68s.
Removing template package using yarnpkg...
yarn remove v1.22.10
[...]
Done in 4.42s.
Created git commit.
Success! Created my-app at /home/erik/dev/js/my-app
[...]
Happy hacking!
~/dev/js/my-app[master]?y start
yarn run v1.22.10
$ react-scripts start
/home/erik/dev/js/my-app/node_modules/tapable/lib/HookCodeFactory.js:383
args({ after,after } = {}) {
^^^^^
SyntaxError: Duplicate parameter name not allowed in this context
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/erik/dev/js/my-app/node_modules/tapable/lib/SyncBailHook.js:8:25)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
error Command Failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
~/dev/js/my-app[master]?
~/dev/js/my-app[master ?]?npm -v
6.14.10
~/dev/js/my-app[master ?]?node -v
v14.15.4
~/dev/js/my-app[master ?]?y -v
1.22.10
~?whereis yarn
yarn: /home/erik/.nvm/versions/node/v14.15.4/bin/yarn
但是如果我运行 npm i && npm start
,这会起作用。在此之后,yarn start
可以工作,但并不理想。
这也发生在其他项目中,事实上,我正在尝试设置一个更复杂的 React 应用程序。
似乎纱线不是“~编译/转译~”(动词是什么?)模块正确,我的文件看起来像:
/**
* Gets the source code for the given node.
* @param {ASTNode} [node] The AST node to get the text for.
* @param {int} [afterCount] The number of characters after the node to retrieve.
* @param {int} [afterCount] The number of characters after the node to retrieve.
* @returns {string} The text representing the AST node.
* @public
*/
getText(node,afterCount,afterCount) {
if (node) {
return this.text.slice(Math.max(node.range[0] - (afterCount || 0),0),node.range[1] + (afterCount || 0));
}
return this.text;
}
我同事的样子:
/**
* Gets the source code for the given node.
* @param {ASTNode} [node] The AST node to get the text for.
* @param {int} [beforeCount] The number of characters before the node to retrieve.
* @param {int} [afterCount] The number of characters after the node to retrieve.
* @returns {string} The text representing the AST node.
* @public
*/
getText(node,beforeCount,afterCount) {
if (node) {
return this.text.slice(Math.max(node.range[0] - (beforeCount || 0),node.range[1] + (afterCount || 0));
}
return this.text;
}
我一周前重新安装了 Ubuntu。更改 nvm 版本甚至使用默认的 ubuntu nodejs 包都不能解决问题。
我尝试了不同的纱线和节点版本,结果相同。
Github 中的文件是正确的:https://github.com/webpack/tapable/blob/v1.1.3/lib/HookCodeFactory.js#L383,但是我代码中的 package.json 版本是最新的,并且是一样的。
我注意到其他类似的错误,这些错误似乎都与作业前/后作业有关。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)