问题描述
运行npm start时出现此错误 用过的snowpack.dev https://www.snowpack.dev/
[snowpack] ! updating dependencies...
[snowpack] ! installing dependencies…
[snowpack] Package "abstracts/variables" not found. Have you installed it?
[snowpack] Install failed.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: `snowpack dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start 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! C:\Users\lenovo\AppData\Roaming\npm-cache\_logs\2020-09-15T12_18_05_035Z-debug.log
PS G:\antonio\projects\react\app>
解决方法
您是否在 baseUrl
中使用 tsconfig.json
?
如果您通过 ./src/abstracts
配置将 abstracts/[whateverfile]
导入为 baseUrl
,则需要在您的 snowpack 配置文件中设置别名 (Docs here)。
-
创建
snowpack.config.js
(如果您还没有这样做的话)。将它放在您的应用程序的根目录中,与您的package.json
一起。 -
在
snowpack.config.js
中,添加:
module.exports = {
...
alias: {
abstracts: '/src/abstracts',// continue for remaining directories in /src
},...
}